aboutsummaryrefslogtreecommitdiff
path: root/clojure/src/step0_repl.clj
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-03-24 16:32:24 -0500
committerJoel Martin <github@martintribe.org>2014-03-24 16:32:24 -0500
commit3169070063b2cb877200117ebb384269d73bcb93 (patch)
tree23de3db1ea5c37afd21a45b6ed7771f56a08c0c4 /clojure/src/step0_repl.clj
downloadmal-3169070063b2cb877200117ebb384269d73bcb93.tar.gz
mal-3169070063b2cb877200117ebb384269d73bcb93.zip
Current state of mal for Clojure West lighting talk.
Diffstat (limited to 'clojure/src/step0_repl.clj')
-rw-r--r--clojure/src/step0_repl.clj26
1 files changed, 26 insertions, 0 deletions
diff --git a/clojure/src/step0_repl.clj b/clojure/src/step0_repl.clj
new file mode 100644
index 0000000..7a050c7
--- /dev/null
+++ b/clojure/src/step0_repl.clj
@@ -0,0 +1,26 @@
+(ns step0-repl
+ (:require [readline]))
+
+
+;; read
+(defn READ [& [strng]]
+ (let [line (if strng strng (read-line))]
+ strng))
+
+;; eval
+(defn EVAL [ast env]
+ (eval (read-string ast)))
+
+;; print
+(defn PRINT [exp]
+ exp)
+
+;; repl
+(defn rep [strng] (PRINT (EVAL (READ strng), {})))
+
+(defn -main [& args]
+ (loop []
+ (let [line (readline/readline "user> ")]
+ (when line
+ (println (rep line))
+ (recur)))))