4 ms·
this is great! (both because of content and presentation tool) so why is there a limitation of just one argument? since lambda expressions can receive multiple
by SonicSoul 13y ago
this is great! (both because of content and presentation tool)
so why is there a limitation of just one argument? since lambda expressions can receive multiple arguments, and simply resolve them in order, why can't functional programming do the same? is this just a stylistic thing?
- tel 13y agoBecause lambda expressions of just one argument are the simplest possible thing that works. One of the neat things you learn if you start playing with lambda expressions in languages with algebraic data types is that multiple argument functions are modeled perfectly as functions which take single, tuple-typed arguments. f :: (Int, Int) -> Int f = \(a, b) -> a + b ghci> :t curry f curry f :: Int -> Int -> Int ghci> f(3,2) 5 So, if you let your lambdas be as simple as possible then you naturally get "multi-argument lambdas" as the combination of tuples and lambdas.