OK... I'm trying to take Clojure for a spin on Project Euler problems.
I have source files for each problem that I have solved and although I
can refer to and invoke any one of them explicitly from a main class,
I cannot seem to figure out how to refer to them all at once so that I
can choose to run any one of them at runtime. Here is some code:
main.clj
--------
(ns com.dankefford.projecteuler.main
(:gen-class)
(:use [com.dankefford.projecteuler.problems.1])
)
(defn -main []
(run)
)
1.clj
-----
(ns com.dankefford.projecteuler.problems.1
(:gen-class)
(:use [com.dankefford.projecteuler.util arithmetic])
)
(defn run []
(print "The sum of all the multiples of 3 or 5 below 1000 is: ")
(println (reduce + (filter #(or (divides? % 3) (divides? % 5))
(range 1 1000))))
)
It does not look like wildcarding is supported in the ns macro and it
seems silly to explicitly nominate each class that I want to have at
my disposal. Am I thinking about this all wrong?
--
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