I'm new on clojure and it's not clear how exactly work lazy-sequence internally or to be more specific a function that return a lazy sequence mean that the result will be computed only when is needed. For example in the following example:
(defn fc-lazy [ fn xs ]
(lazy-seq
(if-let [ xss (seq xs) ]
(cons (fn (first xs)) (fc-lazy fn (rest xs)))
())))
when I call:
(fc-lazy #(* % 2) (range 100))
result will be a collection of 100 numbers, this mean that the fc-lazy function will be called for 100 times, what is not clear to me; in this case we have on stack all those 100 functions, if NOT, why ?
Thanks.