Skip to content

Instantly share code, notes, and snippets.

@netoneko
Created October 28, 2013 00:06
Show Gist options
  • Save netoneko/7189443 to your computer and use it in GitHub Desktop.
Save netoneko/7189443 to your computer and use it in GitHub Desktop.
(require 'clojure.string)
(def records {})
(def commands {})
(def commands
(assoc commands "add"
(fn [k v] (def records (assoc records k v)))))
(def commands
(assoc commands "delete"
(fn [person] (def records (dissoc records person)))))
(def commands
(assoc commands "print"
(fn [] (println records))))
(while true
(print "> ")
(flush)
(def line (clojure.string/trim (read-line)))
(def tokens (clojure.string/split line #"\s"))
(if (contains? commands (first tokens)) (
(defn command [& args] (get commands (first tokens)))
(println command)
(def args (rest tokens))
(println args)
(apply command args)
(flush))))
@kagel
Copy link

kagel commented Oct 28, 2013

it should be (apply (command) args)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment