Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Mire: lookup commands by keyword

  • Loading branch information...
commit 62ad5924e22fdef0bd6d320b0a88c6fd6752c163 1 parent 2c861ca
Andreas Pauley authored

Showing 1 changed file with 8 additions and 5 deletions. Show diff stats Hide diff stats

  1. +8 5 PeepCode/Clojure/mire/src/mire/commands.clj
13 PeepCode/Clojure/mire/src/mire/commands.clj
@@ -13,14 +13,17 @@
13 13 "Get a description of the current room"
14 14 (:desc *current-room*))
15 15
16   -(def commands {"move" move,
17   - "north" (fn [] (move :north))
18   - "look" look})
  16 +(def commands {:move move,
  17 + :north (fn [] (move :north))
  18 + :east (fn [] (move :east))
  19 + :south (fn [] (move :south))
  20 + :west (fn [] (move :west))
  21 + :look look})
19 22
20 23 (defn execute
21 24 "Execute a command passed from the client"
22 25 [input]
23 26 (let [input-words (re-split #"\s+" input)
24   - command (first input-words)
  27 + command (keyword (first input-words))
25 28 args (rest input-words)]
26   - (apply (commands command) args)))
  29 + (apply (command commands) args)))

0 comments on commit 62ad592

Please sign in to comment.
Something went wrong with that request. Please try again.