5 ms·
I really liked the postfix and prefix notation in Mathematica. These three all mean the same: f[x] f@x x // f It matches the flow of thought more naturally
by mr_mitm 4y ago
I really liked the postfix and prefix notation in Mathematica. These three all mean the same:
f[x]
f@x
x // f
It matches the flow of thought more naturally when hammering out a couple of one-liners.
- japanman425 4y agoHow is that third one readable at all? I’d assume it meant integer division.
- deleted 4y ago[deleted]
- mr_mitm 4y agoThat's just a matter of habit. The exact symbol isn't important anyway.
- Smaug123 4y agoMathematica uses a lot of syntactic sugar. You will find all Mathematica code unreadable until you've learned to read it; `//` is no exception.
- contravariant 4y agoI find Mathematica code unreadable full stop. Its convenient when writing though.
- mr_mitm 4y agoI see Mathematica as a shell for math. You can write long programs or modules in it, sure, but very often you're simply typing up a couple of lines to check some computation or visualize an expression which you won't even save, in which case readability is secondary.
- carry_bit 4y agoIt's usually used with the formatting functions, so you have something like: <Some big expression here> // Column Useful where the function in question is an "afterthought".
- rwmj 4y agoYou're writing something and you decide you want to apply 'f' to it, so you type '// f' (instead of backspacing like a caveman). It's actually rather convenient.
- japanman425 4y agoAh neat.
- adiM 4y agoJulia also has x |> f as a syntax sugar for f(x) and is useful for the same reason as Mathematica.
- Smaug123 4y ago(I don't know where the pipeline operator originated, but F# certainly had it before Julia, by the way.)