News for hackers. Stuff that matters.
Re:Functional Programming in 5 Minutes by chenglou on Sunday May 19, 2013 @01:45PM (#5733681)
It never occurred to me to try some currying in CoffeeScript, but man this looks expressive:

  f = (x) -> (y) -> x + y
  g = f 6
Re:Functional Programming in 5 Minutes by tel on Sunday May 19, 2013 @02:32PM (#5733893)
For comparison, here's the same thing in Haskell

    f = \x -> \y -> x + y
    g = f 6
with the added bonus of automatic documentation

    ghci> :t f
    f :: Integer -> Integer -> Integer
    ghci> :t g
    g :: Integer -> Integer
    ghci> :t uncurry f
    uncurry f :: (Integer, Integer) -> Integer
Re:Functional Programming in 5 Minutes by callmecosmas on Sunday May 19, 2013 @04:00PM (#5734184)
You don't actually need the second lambda since all Haskell functions take one argument, so you can just do

  f = \x y -> x + y
and you'll have an implicit lambda before the y.
Re:Functional Programming in 5 Minutes by tel on Sunday May 19, 2013 @05:25PM (#5734447)
Yes, but that has an obvious lack of syntactic parallelism, one especially important when talking about currying since you might be tempted to relate that to the coffee script

    (X, y) -> x+y
It also has a subtly different performance characteristic in GHC, it turns out. Same semantics though.
Re:Functional Programming in 5 Minutes by alipang on Sunday May 19, 2013 @04:12PM (#5734225)
And of course it has operator segmenting so you can just write

    f = (+)
Re:Functional Programming in 5 Minutes by Peaker on Sunday May 19, 2013 @05:10PM (#5734406)
Or simply:

  f x y = x + y