Original Post
Ok, today I decided to do something dangerous and actually learn a purely functional language - Haskell. But I'm already stuck in function composition. Ok, so let's say we have 2 functions: Now, I want to create a new function that takes (x y), adds them and then squares the result. I understand I can't just do: (square.add) 2 3 because Haskell functions are curried. Haskell evaluates the result of "add 2", which is of type int->int and passes it to square which needs int, so it won't work. I can do: (square.add 2) 3 but what I really want the created function to take 2 arguments. So I see that I must do : ((square.).add) 2 3 Haskell evaluates "add 2" and passes the result to the composition function (.), which creates the function (square.add 2) and the rest works like in the previous example. But beyond that, I'm stuck. What if "add" had 3,4 or more parameters? How should I write it then?(if you can, do some explaining of your solution) Thanks in advance.
add x y = x + y
square x = x * x