Currently working through the Racket Guide at https://docs.racket-lang.org and reading up on lambda functions. The explanation of their usefulness is lucid, but I am not sure I quite grasp the order in which such functions are evaluated. Consider the following example from the Guide:
(define (twice f v)
(f (f v)))
(define (make-add-suffix s2)
(lambda (s) (string-append s s2)))
(twice (make-add-suffix "!") "hello")
The function call to twice
here is said to evaluate to "hello!!"
. Here is my guess at what the evaluation process looks like:
(twice (make-add-suffix "!") "hello")
((make-add-suffix "!") ((make-add-suffix "!") "hello")
((make-add-suffix "!") (string-append "hello" "!"))
(string-append (string-append "hello" "!") "!")
(string-append "hello!" "!")
"hello!!"
Is this an accurate assessment, or have I missed something?