According to a Mathematica textbook, we can write N[x,n] by using infix notation as x ~ N ~ n. How about other functions with one argument or more than 2 arguments, is it possible?
Asked
Active
Viewed 515 times
4
kiss my armpit
- 757
- 4
- 15
3 Answers
13
One can use Sequence for such purposes
Sequence[]~f~x
x~f~Sequence[]
f[x]
f[x]
x1~f~Sequence[x2, x3]
f[x1, x2, x3]
ybeltukov
- 43,673
- 5
- 108
- 212
3
If, in an input cell, you type the expression,
x1 ~ f ~ x2 ~ f ~ x3
it will evaluate to
f[f[x1,x2],x3]
UNLESS the symbol f has the attribute Flat in which case it will evaluate to
f[x1,x2,x3]
DSkinner
- 91
- 6
Flat. TheInfixfunction that you refer to is only a typesetting function. – rm -rf Dec 28 '13 at 22:13@. edit: @rm -rf: Is the documentation wrong? – shrx Dec 28 '13 at 22:13F1on~takes you there... theInfixfunction is more for typesetting than the function calls notation. For instance,Prefix[f[x]]will give youf@x, but thisf@xis not equivalent to typing outf@x(try evaluating the two). Check out the full forms:Infix[f[x1, x2, x3]] // FullFormandx1~f~x2~f~x3 // FullForm– rm -rf Dec 28 '13 at 22:19