I understand that part but when I look at the map part there is no x. When I look at the function no x. So how does Clojure know what the value of x is.
Roelof Op vrijdag 24 oktober 2014 15:06:05 UTC+2 schreef Laurens Van Houtven: > Hi Roelof, > > On 24 Oct 2014, at 15:00, Roelof Wobben <[email protected] <javascript:>> > wrote: > > > (defn second-elements [collection] > > (let [second-item (fn [x] (get x 1))] > > (map second-item collection))) > > > > one thing I m not sure I understand complete. x is the output of the > map command, if so, how does Clojure know that. > > Not quite. the map function evaluates to a sequence of items: the items in > the input collection, except with f applied to each one of them. > > This function: > > > (fn [x] (get x 1)) > > > … takes a single item and does something to it (gets the first element > out). `map` is responsible for calling it on each item. > > hth > lvh > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
