Hello
working on Project Euler exercise 24 I solved the right answer with
this solution
(use 'clojure.contrib.combinatorics)
(defn run-euler-024 []
(binding [max 0]
(let [perms (take 1000000 (lex-permutations [0 1 2 3 4 5 6 7 8
9]))]
(doseq [perm perms]
(set! max perm)))
max))
The solution only works with a var name that equals to a Clojure name
(here "max").
Changing "max" to "res" results in java.lang.Exception: Unable to
resolve var: res in this context
(but works also with "vec" etc.)
Is Clojure's behaviour substantiated?
How do you access an element at a given place in a lazy sequence in a
more idiomatic way?
Thanks for your advice.
~ gL
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---