1 Applying Lambdas
2 curried-add
3 curry2
4 curry3
5 in-list-many?

Lab 6

1 Applying Lambdas

What should this expression produce?

  ((lambda (x) (+ x 2)) 3)

Try running it. Did it produce what you expected?

Next: what should this expression produce?

  ((lambda (f g) (f (g 3)))
   (lambda (x) (+ x 3))
   (lambda (x) (* x 2)))

Try to figure it out first! Then evaluate it.

2 curried-add

Develop the curried-add function. It takes a number ’a’ and returns a function that takes a number ’b’ and returns a+b. In other words, it has the type

  (number -> (number -> number))

... where (t1 -> t2) is the type of a function that takes a t1 and produces a t2.

3 curry2

Develop the curry2 function; it takes a function of two arguments, and produces a function that takes one argument and produces a function that takes one argument and produces the result of calling the input function on the two given arguments. In other words, it has the type

  (a b -> c) -> (a -> (b -> c))

... for types a,b, and c. You will need lambda for this.

4 curry3

Develop the curry3 function; it takes a function of three arguments, and produces a function that takes one argument and produces a function that takes one argument and produces a function that takes one argument and produces the result of calling the input function on the three given arguments. In other words, it has the type

  (a b c -> d) -> (a -> (b -> (c -> d)))

... for types a,b,c, and d. You will need lambda for this.

Show me this function when it’s complete for lab credit.

5 in-list-many?

Develop the contains? function, that consumes a list and a symbol and returns true exactly when the symbol occurs in the list.

Use curry2 and in-list? to develop in-list-many?, that consumes a source list of symbols and a list of query symbols, and returns a list of booleans indicating for the corresponding element of the query list whether it occurs in the source list.