Question
Recall that an F# function that takes two arguments can be coded in either uncurried form (in which case it takes a pair as its
Recall that an F# function that takes two arguments can be coded in either uncurried form (in which case it takes a pair as its input) or curried form (in which case it takes the first argument and returns a function that takes the second argument). In fact it is easy to convert from one form to the other in F#. To this end, define an F# function curry f that converts an uncurried function to a curried function, and an F# function uncurry f that does the opposite conversion. For example,
> (+);;
val it : (int -> int -> int) =
> let plus = uncurry (+);;
val plus : (int * int -> int)
> plus (2,3);;
val it : int = 5
> let cplus = curry plus;;
val cplus : (int -> int -> int)
> let plus3 = cplus 3;;
val plus3 : (int -> int)
> plus3 10;;
val it : int = 13
What are the types of curry and uncurry?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started