Hi, maybe this question was already put it here, but can someone explain how exactly work internal a function wrapped with lazy-seq keyword. For example in the below code sample:
( defn test-fc "sum of all collection elements using recursion and laziness" [coll] (letfn [(sum-fc [sum coll] (if (empty? coll) (cons sum nil) (lazy-seq(sum-fc (+ sum (first coll)) (rest coll)))) ) ] (sum-fc 0 coll) ) ) if I test the function: (test-fc (range 5)) I got the right result, if I continue to test with bigger number I don't got StackoverflowException, but if run (test-fc (range 210432423543654675765876879)) I didn't get StackoverflowEx but the application didn't return any result, because take to much time to compute this ? How exactly work this internally and how is removed recursion( inside call sum-fc with new parameters) from the flow in this case ? From what I saw in java code of LazySeq class and clojure source code, it's made a list with LazySeq object and in my opinion in that list the LazySeq object contain enough information to compute the requested item and in this way is removed recursion and implicit StackoverflowException issue, if I understand something wrong please explain to me. I test this function from IntellijIDEA + LaClojure plugin. Thanks Sorin. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.