Skip to content
This repository has been archived by the owner on Jul 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #4 from tidalcycles/operators
Browse files Browse the repository at this point in the history
add level of headers
  • Loading branch information
bgold-cosmos authored Jan 10, 2017
2 parents 908ecb6 + 9ee2f7b commit e9579a8
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions _functions/operators/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ category: operators
weight: -8
---

## specific to Tidal
### specific to Tidal

The general rule for things that combine patterns is that they use the structure of the pattern on the *left*.

### `|+|`, `|*|`, `-`, `/`
#### `|+|`, `|*|`, `-`, `/`
Operate on *ParamPatterns*, and perform the arithmetic operation if the two parameters are the same (such as `speed` and `speed`), or simply merge the parameters just as `#` would if the parameters are different.
~~~haskell
speed "1 2 3 4" |+| speed "2"
Expand All @@ -17,16 +17,16 @@ is the same as
speed "3 4 5 6"
~~~

### `#`, `|=|`
#### `#`, `|=|`
They mean the same thing: they merge *ParamPatterns* together

### `###`, `***`, `+++`, `///`
#### `###`, `***`, `+++`, `///`
These take a **list** of *ParamPatterns* as their second argument, and merge them all together with the relevant arithmetic operator. Can simplify long expressions.
~~~haskell
s "bd sn" # "speed "1.2" *** [speed "2", crush "4"]
~~~
### `<~`, `~>`
#### `<~`, `~>`
These time-shift the pattern on the RHS by the number of cycles on the LHS.
~~~haskell
0.25 ~> "a b c d"
Expand All @@ -36,7 +36,7 @@ is the same as
"d a b c"
~~~
### `<~>`
#### `<~>`
Pattern replacement: takes the elements of the second pattern and makes a new pattern using the structure of the first
~~~haskell
"x x x" <~> "bd sn"
Expand All @@ -50,7 +50,7 @@ one cycle and
~~~
the next
### `<<~`, `~>>`
#### `<<~`, `~>>`
Pattern rotation, these move the elements of the pattern without changing the structure of the pattern
~~~haskell
1 ~>> "a ~ b c"
Expand All @@ -60,19 +60,19 @@ is the same as
"c ~ a b"
~~~
### `!!!`
#### `!!!`
List indexing with built-in modulo so you can't go past the end of the list
~~~haskell
[1 2 3 4]!!!5
~~~
returns `2`
## useful Haskell operators
### useful Haskell operators
### `<$>`
#### `<$>`
A synonym for `fmap`, useful for mapping numerical functions so they work on patterns.
### `<*>`
#### `<*>`
A synonym for `ap`, useful for promoting functions to work with patterns.
~~~haskell
(+2) <$> "1 2 3 4"
Expand All @@ -83,11 +83,11 @@ is the same as `"3 4 5 6"`
~~~
is also the same
### `!!`
#### `!!`
Haskell's way of doing list indexing
### `$`
#### `$`
An alternative to parentheses, means "evaluate everything on the right first"
### `.`
#### `.`
Function composition, needs functions that return the same type as their argument

0 comments on commit e9579a8

Please sign in to comment.