3 ms·
inl add a b = a + b inl f = add 1 f 2, f 3 is just awesome
by rurban 8y ago
inl add a b = a + b
inl f = add 1
f 2, f 3
is just awesome
- skrebbel 8y agoThat's just normal partial function application, right? Or am I missing something special?
- rurban 8y agoYes, but I adore the simple syntax. inl add a b = a + b is basically a macro #define add(a,b) a+b inl f = add 1 is a macro #define f add(1) f 2, f 3 but e.g. inl f = add c would create a closure to capture c. inl would guarantee that the capturing is lexical, not dynamic. There's no need for the comma operator in args, comma is to create lists.
- rurban 8y agooops: inl f(x) = add(1,x) of course
- TurboHaskal 8y agoIt blew my mind when I saw it on K. I just wasn't expecting it. add:{x+y} f:add 1 f 2 3
- catwell 8y agoSimilarly, Haskell would be: add = (+) f = add 1 f 2 This kind of syntax is great for small code samples or to play in a CLI, but in larger programs more traditional (verbose) syntax works better for me. YMMV.
- moomin 8y agoThe syntax, though, is part of a more important point: all functions have one input and one output. This _massively_ simplifies other things. Also, and this isn’t really an FP point, if you’ve got a lot of positional parameters you’re already Doing It Wrong.