News for hackers. Stuff that matters.
Re:Functional Programming in 5 Minutes by mcintyre1994 on Sunday May 19, 2013 @04:07PM (#5734206)
Sorry for my ignorance here, but that function takes two parameters right? The slides seemed to suggest that functional languages should use only one. So I guess my question is how come you're using two and not currying?
Re:Functional Programming in 5 Minutes by andolanra on Sunday May 19, 2013 @08:04PM (#5735029)
It's not a matter of should so much as can. In some languages (e.g. Haskell), functions are curried-by-default; in others (e.g. Lisps), functions are uncurried-by-default. In each of these, I could (if I wanted) write either version, e.g.

    -- Curried and uncurried add in Haskell:
    curriedAdd :: Int -> Int -> Int
    curriedAdd x y = x + y
    
    uncurriedAdd :: (Int, Int) -> Int
    uncurriedAdd (x, y) = x + y

    ;; Curried and uncurried add in Scheme:
    (define (curried-add x)
      (lambda (y) (+ x y)))
    
    (define (uncurried-add x y)
      (+ x y))
Haskell chooses to make curried the default, but allows you to write uncurried functions if you'd like. Lisp chooses the opposite.
Re:Functional Programming in 5 Minutes by dllthomas on Monday May 20, 2013 @08:16AM (#5737193)
Also, just generally, currying is a transformation. You can do it by hand, but it can also be done mechanically, either automatically by the language in certain situations, or by applying (easy to define and usually included anyway) curry and uncurry functions where appropriate.
Re:Functional Programming in 5 Minutes by mcintyre1994 on Monday May 20, 2013 @06:23AM (#5736842)
Ah okay I see, thanks!