clojure: stack overflow over range -


i trying solve problem 60 @ 4clojure.com

sequence reductions

my solution works last 2 cases fails first case in handling range.

here solution

(fn reds ([func lst](if (empty? lst)            []            (reds func (first lst) (rest lst)))) ([func init lst](if (empty? lst)            (println "hi")            (concat [init] (reds func (func init (first lst)) (rest lst))))) ) 

i think because keep calling function on more terms of infinite list . how do better?

update : solved using lazy-seq


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -