Hi!
Just created this solution for the Number Maze problem on 4clojure:
http://www.4clojure.com/problem/106
(
(fn [a b]
(letfn [(nummaze [a b len]
(cond
(= len 0) false
(= a b) true
(nummaze (* 2 a) b (dec len)) true
(and (even? a) (nummaze (quot a 2) b (dec len))) true
(nummaze (+ 2 a) b (dec len)) true
:else false))]
(first (filter #(nummaze a b %) (range 15)))))
;(first (filter #(nummaze a b %) (range)))))
9 2)
Normally the program returns instantly. The strange thing is that if I
uncomment the line with the unrestricted (range) then it churns for minutes
but gives the correct answer. So it is evaluated lazily since it gives an
answer.
Is it a codegen bug or just the effect of chunked sequences? Is so why?
Thanks,
Andrew
--
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