Created
January 23, 2011 01:26
-
-
Save anonymous/791715 to your computer and use it in GitHub Desktop.
Can you split out condp?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def commands (condp = cmd | |
"abc" (println "ABC") | |
"def" (println "DEF") | |
"ghi" (println "GHI"))) | |
(let [[cmd & args] (split message #" ")] | |
commands) | |
;; When 'commands' is evaluated in this context it will not pick up | |
;; on 'cmd' being defined in the current context. | |
; Questions: | |
;; How should one go about splitting out a condp into a def or defn? | |
;; What about the pairs inside the condp? | |
;;; For instance, what is the preferred method of extracting | |
;;; the conditions "abc", "def", and "ghi" into their own def? | |
;;; They need structure if this is the case, no? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment