2022-09-19 21:13:58 +02:00
|
|
|
|
# Lista wbudowanych operatorów języka Musique
|
|
|
|
|
|
|
|
|
|
## Operatory arytmetyczne
|
|
|
|
|
|
|
|
|
|
- `+` – operator:
|
2022-09-19 23:42:20 +02:00
|
|
|
|
- dodawania (liczby całkowite i ułamki):
|
2022-09-19 23:41:21 +02:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
> 2 + 3
|
|
|
|
|
5
|
|
|
|
|
> (1/3) + (1/4)
|
|
|
|
|
7/12
|
|
|
|
|
> 1 + (up 10)
|
|
|
|
|
[1; 2; 3; 4; 5; 6; 7; 8; 9; 10]
|
|
|
|
|
```
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 23:42:20 +02:00
|
|
|
|
- inkrementacji zmiennej (liczby lub akordu, w tym w szczególności pojedynczeń nuty):
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 23:41:21 +02:00
|
|
|
|
```
|
|
|
|
|
> c + 1
|
|
|
|
|
c#
|
|
|
|
|
c4 + 2
|
|
|
|
|
hord[d; f#]
|
|
|
|
|
```
|
2022-09-19 21:13:58 +02:00
|
|
|
|
|
|
|
|
|
- `-` – operator odejmowania/dekrementacji – analogicznie do operatora `+`;
|
|
|
|
|
|
|
|
|
|
- `*` – operator:
|
2022-09-19 23:39:23 +02:00
|
|
|
|
|
2022-09-19 23:42:20 +02:00
|
|
|
|
- mnożenia (liczby całkowite i ułamki):
|
2022-09-19 23:39:23 +02:00
|
|
|
|
|
2022-09-19 23:41:21 +02:00
|
|
|
|
```
|
|
|
|
|
> 2 * 5
|
|
|
|
|
10
|
|
|
|
|
> (1/3) * (1/4)
|
|
|
|
|
1/12
|
|
|
|
|
> 2 * (up 10)
|
|
|
|
|
[0; 2; 4; 6; 8; 10; 12; 14; 16; 18]
|
|
|
|
|
```
|
2022-09-19 23:39:23 +02:00
|
|
|
|
|
2022-09-19 23:42:20 +02:00
|
|
|
|
- powtarzania – zwraca określoną liczbę powtórzeń danego dźwięku:
|
2022-09-19 23:39:23 +02:00
|
|
|
|
|
2022-09-19 23:41:21 +02:00
|
|
|
|
```
|
|
|
|
|
> a * 4
|
|
|
|
|
[a; a; a; a]
|
|
|
|
|
> a3 * 4
|
|
|
|
|
[chord[a; c]; chord[a; c]; chord[a; c]; chord[a; c]]
|
|
|
|
|
```
|
2022-09-19 21:13:58 +02:00
|
|
|
|
|
2022-09-19 23:34:25 +02:00
|
|
|
|
- `/` – operator dzielenia – *wektor może być wyłącznie dzielną*:
|
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
> 4 / 2
|
|
|
|
|
2
|
|
|
|
|
> 5 / 7
|
|
|
|
|
5/7
|
|
|
|
|
> (2/3) / (3/5)
|
|
|
|
|
10/9
|
2022-09-19 23:34:25 +02:00
|
|
|
|
> (up 10) / 2
|
|
|
|
|
[0; 1/2; 1; 3/2; 2; 5/2; 3; 7/2; 4; 9/2]
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
|
|
|
|
- `%` – operator działania modulo (wynikiem jest reszta z dzielenia) – *nie działa dla ułamków*, *wektor może być wyłącznie dzielną*:
|
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
> 3 % 3
|
|
|
|
|
0
|
|
|
|
|
> 6 % 5
|
|
|
|
|
1
|
2022-09-19 23:34:25 +02:00
|
|
|
|
> (up 10) % 2
|
|
|
|
|
[0; 1; 0; 1; 0; 1; 0; 1; 0; 1]
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
- `**` – operator potęgowania – *wykładnikiem nie może być ułamek*:
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
> 2 ** 8
|
|
|
|
|
256
|
|
|
|
|
> (2/3) ** 3
|
|
|
|
|
8/27
|
2022-09-19 23:34:25 +02:00
|
|
|
|
> (up 10) ** 2
|
|
|
|
|
[0; 1; 4; 9; 16; 25; 36; 49; 64; 81]
|
|
|
|
|
> 2 ** (up 10)
|
|
|
|
|
[1; 2; 4; 8; 16; 32; 64; 128; 256; 512]
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Operatory porównawcze
|
|
|
|
|
|
|
|
|
|
- `!=` – operator "nie równa się":
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
> 2 != 3
|
|
|
|
|
true
|
|
|
|
|
> a != a
|
|
|
|
|
false
|
2022-09-19 23:34:25 +02:00
|
|
|
|
> 3 != (up 5)
|
|
|
|
|
[true; true; true; false; true]
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
- `<` – operator "mniejsze niż":
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
> 2 < 3
|
|
|
|
|
true
|
|
|
|
|
> a < a
|
|
|
|
|
false
|
2022-09-19 23:34:25 +02:00
|
|
|
|
> 3 < (up 5)
|
|
|
|
|
[true; true; true; false; false]
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
- `<=` – operator "mniejsze lub równe":
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
> 2 <= 3
|
|
|
|
|
true
|
|
|
|
|
> a <= a
|
|
|
|
|
true
|
|
|
|
|
> 3 <= 2
|
|
|
|
|
false
|
2022-09-19 23:34:25 +02:00
|
|
|
|
> 3 <= (up 5)
|
|
|
|
|
[true; true; true; true; false]
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
- `==` – operator "równe":
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
> 2 == 3
|
|
|
|
|
false
|
|
|
|
|
> a == a
|
|
|
|
|
true
|
2022-09-19 23:34:25 +02:00
|
|
|
|
> 3 == (up 5)
|
|
|
|
|
[false; false; false; true; false]
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
- `>` – operator "większe niż":
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
> 2 > 3
|
|
|
|
|
false
|
|
|
|
|
> a > a
|
|
|
|
|
true
|
2022-09-19 23:34:25 +02:00
|
|
|
|
> 3 > (up 5)
|
|
|
|
|
[false; false; false; false; true]
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
- `>=` – operator "większe lub równe":
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
> 2 >= 3
|
|
|
|
|
false
|
|
|
|
|
> a >= a
|
|
|
|
|
true
|
|
|
|
|
> 3 >= 2
|
|
|
|
|
true
|
2022-09-19 23:34:25 +02:00
|
|
|
|
> 3 >= (up 5)
|
|
|
|
|
[false; false; false; true; true]
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:16:11 +02:00
|
|
|
|
## Pozostałe operatory
|
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
- `.` – operator indeksu (zwraca wskazany element, liczone od 0):
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
> A:=[1; 3; 5]
|
|
|
|
|
> A . 1
|
|
|
|
|
3
|
2022-09-19 23:34:25 +02:00
|
|
|
|
> (up 7).4
|
|
|
|
|
3
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
- `&` – operator łączenia:
|
2022-09-19 23:34:25 +02:00
|
|
|
|
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|
|
|
|
|
> c & a
|
|
|
|
|
chord[c; a]
|
|
|
|
|
> [1;3;5] & [2;4;6]
|
|
|
|
|
[1; 3; 5; 2; 4; 6]
|
2022-09-19 23:34:25 +02:00
|
|
|
|
> (up 7) & (down 9)
|
|
|
|
|
[0; 1; 2; 3; 4; 5; 6; 8; 7; 6; 5; 4; 3; 2; 1; 0]
|
2022-09-19 21:13:58 +02:00
|
|
|
|
```
|