Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
;; make-addX: num -> (lambda num -> num)
;; returns a function that adds its input to the original x input.
;; Examples:
(check-expect ((make-addX 3) 5) 8)
(check-expect ((make-addX 3) -2) 1)
(check-expect ((make-addX -5) 5) 0)
(check-expect ((make-addX -5) -2) -7)
(define (make-addX x)
   (lambda (y) (+ x y))) 

Problem: A "pure" lambda cannot be recursive because it  We can't write a recursive algorithm using a lambda function because the lambda cannot refer to itself!   This issue can be solved using more sophisticated lambda function techniques, which are mostly out of the scope of this course, and in Java, which always defines a name for object to use to reference itself.  

Currying

Not a reference to cooking up the delicious spicy South Asian dish, but a rather to  the American mathematician, Haskell Curry, for which the computer language "Haskell" is named.    (To note, please see the link above for currying to see that Haskell Curry was not the original inventor of the process that now bears his name.) 

Currying is technically the process in which a function, which takes n input parameters, creates another function, which only takes n- input parameters.   Mathamatically, this is a type of process is called a "transformation".    We can

What does this mean?  The effect is that the n'th input parameter in the original function