The << | & >>
symbols are typically implemented as bitwise operators someone else will have to explain in more detail… I believe they deal with generating numbers, using binary format… though they might seem esoteric, I believe the main usage is for SC tweets, and staying below 140.
As it turns out, every one of your questions is answered in the same doc page, it’s called “Symbolic notations”
<< >> are either bitwise or Post << “IOstream”
| a single pipe will bitwise, a few fold/clip shortcuts, or call the union of two Set collection, or merge to Rect objects
& will bitwise or call the ‘intersection’ of two sets
|| is logical or, && is logical and… there’s only one way to use these:
`if( x > y && { true || { true } }) { \true } { \false } // you must put the second expression in function brackets, 100% of the time1
I would also put (x > y) in their own parentheses, but this isn’t 100% necessary.
If you aren’t used to control structures, my advice is stick to if
and switch
, because their syntax mirrors other:
if (true || { false }) { \true } {\false}
switch (x) { 1 } { \one } { 2 }{ \two }
or:
if( x > y, \true, \false) // in comma style, function brackets are optional
using the case
statement is the same as using switch(true) { test }{ execute }, though it reads a little clearer
I prefer to the closed bracket syntax, it looks cleaner
there are a few different ways pipe symbols are used in function argument syntax, you’ll have to do your own testing on these
{ |x, n| }
{ |x n| }
{ | x = 8, n = 9| }
{ |x 8 n 9| }
{ |x …n| } // first arg is x, all args after x will be caught in an array, accessible as n within the function… this syntax never requires a comma (it will post an error warning, the comma in this case must be ommited)
The final version is:
{ |…n| } // there are only two ways to use these, either alone, or at the end of ones arg list.
If you aren’t completely familiar with function syntax, you can use this to run a few tests:
(
~use = {
|x 8 y ...z|
Post <<* [x, y] << $\n <<* z <<<* ($\n ! 3); // post everything
x.switch // same as switch (x)
{
5
} {
"five"
} {
8
} {
#[ 8 ]
}; (\x -> x).postln; (\class: x.class).postln;
if(
z.isEmpty
) {
z.reshape(4, 4).printAll
} {
z.printAll
};
}
)
~use.value(8, nil, 100, 101, [102], [ [ 103 ] ])
~use.(5, nil, (…100))
~use.(y: (19, 29…89))