Skip to content

Instantly share code, notes, and snippets.

Created January 23, 2011 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/791715 to your computer and use it in GitHub Desktop.
Save anonymous/791715 to your computer and use it in GitHub Desktop.
Can you split out condp?
(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