1

I am new to Scala and I just started learning it and now trying some exercises. This one in particular I have a trouble understanding.

I understand up to the (f: (A, B) => C) part, but the rest I dont quite get it. Can someone please explain what's happening after the anonymous function part?

Thanks!

This is the function:

def curry[A, B, C](f: (A, B) => C): A => (B => C) = a => b => f(a, b) 
4

1 Answer 1

6
  • def curry a method named "curry"
  • [A, B, C] will deal with 3 different types
  • (f it will receive an argument that we'll name "f"
  • : (A, B) => C) that argument is type "function that takes A,B and returns C"
  • : A => (B => C) "curry" returns type "function that takes A and returns function that takes B and returns C"
  • = here's the "curry" code
  • a => b => f(a, b) function that takes an argument (we'll call "a") and returns a function that takes an argument (we'll call "b") that returns the value returned after "a" and "b" are passed to "f()"
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.