Permalink
Browse files

Mire: lookup commands by keyword

  • Loading branch information...
1 parent 2c861ca commit 62ad5924e22fdef0bd6d320b0a88c6fd6752c163 Andreas Pauley committed Dec 19, 2009
Showing with 8 additions and 5 deletions.
  1. +8 −5 PeepCode/Clojure/mire/src/mire/commands.clj
@@ -13,14 +13,17 @@
"Get a description of the current room"
(:desc *current-room*))
-(def commands {"move" move,
- "north" (fn [] (move :north))
- "look" look})
+(def commands {:move move,
+ :north (fn [] (move :north))
+ :east (fn [] (move :east))
+ :south (fn [] (move :south))
+ :west (fn [] (move :west))
+ :look look})
(defn execute
"Execute a command passed from the client"
[input]
(let [input-words (re-split #"\s+" input)
- command (first input-words)
+ command (keyword (first input-words))
args (rest input-words)]
- (apply (commands command) args)))
+ (apply (command commands) args)))

0 comments on commit 62ad592

Please sign in to comment.