Last active
September 3, 2019 16:55
-
-
Save mpjdem/11a275520d45bd82fadde01310573b61 to your computer and use it in GitHub Desktop.
'Command' design pattern in Clojure
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
(defn compose-quote [body-part creature-name] | |
(println (str "Go for the " body-part ", " creature-name "!"))) | |
(defn execute [command & args] | |
(Thread/sleep 1000) | |
(apply command args)) | |
(execute compose-quote "eyes" "Boo") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As discussed here:
https://www.mpj-analytics.co.uk/2019/08/29/design-patterns-r-command/
Inspired by:
http://mishadoff.com/blog/clojure-design-patterns/#episode-1-command