Question: Programming in F# Recall that an F# function that takes two arguments can be coded in either uncurried form (in which case it takes a

Programming in F#

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!