3 ms·
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 andolanra 13y ago
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.
- mcintyre1994 13y agoAh okay I see, thanks!
- dllthomas 13y agoAlso, 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.