Can't understand this clojure make-adder example

clojure

Solution

`make-adder` returns a function that takes one parameter (z), the parameter passed in to `make-adder` is used to assign a value to y. `add2` is set equal to the result of evaluating `make-adder` with a parameter of 2. So `add2` is set equal to the function returned from `make-adder`, which (since y has been assigned to the parameter from `make-adder`) looks like

(fn [z] (+ 2 z))

So `(add2 4)` calls this function which evaluates to 6. Does that help?

Problem

I'm trying to read up a bit on Clojure, but I hit a brick wall with the following basic example: ``` (defn make-adder [x] (let [y x] (fn [z] (+ y z)))) (def add2 (make-adder 2)) (add2 4) -> 6 ``` What I don't understand is how is `add2` passing the number 4 to the make-adder function, and how does that function turn assigns that number to z. Thanks in advance!

Original source