Since Clojure 1.3, I am confused about the directory structure needed to build something in Clojure. I am using cake to build and cake repl.
Here is what works. I have a working build directory addr_verify. The main's and ns's name is addr-verify. The project.clj refers to addr-verify as main, and in addr_verify/src there is addr_verify.clj. The ns inside addr_verify.clj refers to the addr-verify name space.
Now, I had a directory mr1, but cake won't compile it right at line 1
(ns mr1
(use ['clojure.string :only '(split)])
(use ['clojure.string :only '(join)])
)
If mr1 is a bad name, what naming convention should I use?
I have tried mr1_app as a directory structure using mr1-app as the main name and ns name. I
For mr1 as the directory and ns name, I get
Caused by: clojure.lang.Compiler$CompilerException: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Comparable, compiling:(mr1.clj:1)
I'm just not getting what I'm doing wrong here, and I know it's probably something really simple.
Edit:
Why does the binary mr1 not have a main?
mr1/project.clj
(defproject mr1 "0.0.1-SNAPSHOT"
:description "TODO: add summary of your project"
:dependencies [[org.clojure/clojure "1.3.0"]
[org.clojure/tools.cli "0.1.0"]]
:main mr1)
mr1/src/mr1.clj
(ns mr1
(:use [clojure.string :only [split]]
[clojure.string :only [join]]))
(def grid-dim (atom '(0 0)))
(def mr1-pos (atom '(0 0)))
(def mr2-pos (atom '(0 0)))
(defn cvt-str-to-int
[string]
(map #(Integer/parseInt %)
(split string #" ")))
(defn prompt-for-grid-dim
[]
(do
(println "Enter the dimensions of the grid (10 10) ")
(cvt-str-to-int (read-line))
))
(defn prompt-for-rover-pos
[rover-num]
(do
(println "Enter rover's initial position on the grid (2 4) ")
(cvt-str-to-int (read-line))
))
(defn prompt-for-rover-moves
[]
(do
(println "Enter rover's moves LMMRM ")
(read-line)
))
(defn -main
[& args]
(do
(reset! grid-dim (cvt-str-to-int (prompt-for-grid-dim)))
(reset! mr1-pos (cvt-str-to-int (prompt-for-rover-pos)))
)
)