The documentation says that using Infix
~, the following input
f[e1,e2,e3,...]
can be rewritten as
e1~f~e2~f~e3~...
So, for the sake of example, consider the following list defined below.
samplelist = {1,2,3,4,5,6,7,8,9}
If I wanted to Partition this list into subsets of 3 with an offset of 2, I would do so by entering
Partition[samplelist, 3, 2]
which would output
{{1, 2, 3}, {3, 4, 5}, {5, 6, 7}, {7, 8, 9}}
Logic then follows that if I wanted to achieve the same result using Infix
, I should input
samplelist~Partition~3~Partition~2
But, this instead returns
{{{1, 2, 3}, {4, 5, 6}}}
What am I doing wrong here? How can I use Infix
correctly to achieve the desired result?
f[a,b,c]
can be given asa~f~b~f~c
, if you read carefully. It says thatInfix
will print it in that form.a~f~b~f~c
is in factf[f[a, b], c]
. Only use~infix~
notation for functions that take two arguments. IMO it's quite confusing to use such a notation when the function is not associative anyway ... $\endgroup$x // f // g // h
is? Either form requires one to know in which direction a particular operator must be read. Or do you prefer explicit bracketing in all such cases? $\endgroup$