Hi all, I'm trying to write a library to perform some statistical and data mining analyses. Clojure has proven a great help here, especially with the incanter library. Writing the code has been kind of an "organic" process (read: no planning), and I ended up with different conceptual groups of functions all within one file. So it makes sense to split this up and start organizing it.
Unfortunately, I am having trouble making the different files (and namespaces) talk to each other, and need some help. Let's say I have two parts in my analysis, each of which require quite a few underlying functions. I would ideally start up a repl and focus on just one analysis: playing with the data, making some graphs, ... I've created a leiningen project with "lein new my-important-project", to which I added two files in src: analysis-1.clj and analysis-2.clj. Directory structure: +- project.clj +- test | +- my-important-project | +- core.clj +- src +- my-important-project +- core.clj +- analysis-1.clj +- analysis-2.clj Let's say this is the contents for those 3 files in src/ (core.clj contains functions and constants that are necessary for both analyses): ==== core.clj ==== (ns my-important-project.core (:use [incanter core io stats charts] [somnium congomongo])) (mongo! :db "the-database") (def some-constant 3.141592) ====analysis-1.clj==== (ns my-important-project.analysis-1) (defn say-from-one [text] (println (str "from 1: " text))) ====analysis-2.clj==== (ns my-important-project.analysis-2) (defn say-from-two [text] (println (str "from 2: " text))) If I want to work on analysis 2, I'd start up the repl in the main directory created by lein (so one *up* from src) and type: user=> (ns '(my-important-project core analysis-2)) user=> (say-from-two "some text") But as you'd have guessed: this doesn't work. The (ns) returns the following error: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IObj (core.clj:1) I've tried different versions of the (ns) function, including a vector as its argument, periods instead of spaces, ... In addition: in the end I'd like to write a script that does the analysis automatically. So instead of going into the repl, I'd "cljr run" a clj file. What should the (ns) bit of that file look like? I've been searching the web for what I'm doing wrong, but haven't found the solution yet. It's quite frustrating to see so many discussions about namespaces, but not being able to solve this issue. Any help very much appreciated, jan. -- 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