category | weight |
---|---|
operators |
-8 |
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.
speed "1 2 3 4" |+| speed "2"
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.
s "bd sn" # "speed "1.2" *** [speed "2", crush "4"]
{: .render }
These time-shift the pattern on the RHS by the number of cycles on the LHS.
0.25 ~> "a b c d"
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
"x x x" <~> "bd sn"
is the same as
"bd sn bd"
one cycle and
"sn bd sn"
the next cycle
Pattern rotation, these move the elements of the pattern without changing the structure of the pattern
1 ~>> "a ~ b c"
is the same as
"c ~ a b"
List indexing with built-in modulo so you can't go past the end of the list
[1 2 3 4]!!!5
returns 2
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.
(+2) <$> "1 2 3 4"
is the same as "3 4 5 6"
(+) <$> "1 2 3 4" <*> "2"
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 with only a single argument unspecified