(var x 5) // Lan 7 or 8 (var x true) // Lan 7 or 8 (var x (lambda w (* w w))) // Lan 8 (anonymous lanmbda expression) (apply f 5) // Lan 7 or 8 (apply (lambda w (+ x x)) 5) // Lang 8 (anonymous lanmbda expression) (fun f (lambda x (* x x))) // Lan 7 or 8 (fun f (lambda x (+ x x))) // Lan 7 or 8 (fun f (lambda x (apply g x))) // Lan 7 or 8 (fun f (lambda x (lambda y (+ y x))) // Lan 8 (anonymous lanmbda expression) f(x) // higher order function { return y => y + x; // nested function return value } g = f(5); g(6); ==> 11 f(5)(6); ==> 11 f(x, g) // higher order function { return x + g(x); // function input parameter } (fun f (lambda x g (+ x (apply g x)))) // Lan 7 or 8 (fun sq (lambda x (* x x))) // Lan 7 or 8 (apply f 5 sq) ==> 30 // Lan 7 or 8 (apply f 5 (lambda y (* y y))) ==> 30 // Lan 8 only Two kinds of higer order functions, function parameters (Lan 7 or 8), function return value (Lan 7 or 8). In Language 8 both kinds of higher order functions can use anonymous lanmbda expressions. (fun h (lambda f g x (if (< x 0) f g))) // Lan 7 or 8 Lan 7 higher order functions lambda expressions Lan 8 anonymous lambda expressions nested lambda expressions closures garbage collection