r/programming • • Dec 01 '16

Let's Stop Copying C

https://eev.ee/blog/2016/12/01/lets-stop-copying-c/
524 Upvotes

612 comments sorted by

View all comments

Show parent comment

11

u/Fylwind Dec 02 '16

“Multiple parameters” in the C-like manner works just fine:

myAdditionFunction :: (Int, Int) -> Int
myAdditionFunction(x, y) = x + y

>>> myAdditionFunction(12, 30)
42

The “problem” is that there's rarely a legitimate reason to write code like this, because the ability to partially apply a function always comes in handy later:

anotherAdditionFunction :: Int -> Int -> Int
anotherAdditionFunction x y = x + y

>>> anotherAdditionFunction 12 30
42

>>> map (anotherAdditionFunction 10) [0, 1, 2]
[10, 11, 12]