Skip to content

Instantly share code, notes, and snippets.

@timmc
Created September 10, 2014 17:43
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 timmc/68ca16d306ee264b409e to your computer and use it in GitHub Desktop.
Save timmc/68ca16d306ee264b409e to your computer and use it in GitHub Desktop.
<-?->
(defmacro <-?->
[& forms]
(let [forms (shuffle forms)]
(reduce (fn [a f]
(let [f (if (seq? f) f (list f))
i (rand-int (inc (count f)))]
(concat (take i f) [a] (drop i f))))
(first forms)
(rest forms))))
adhoc.core=> (macroexpand-1 '(<-?-> 5 inc list count))
((inc (count list)) 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment