Created
September 1, 2019 12:53
-
-
Save craftybones/ebfcaabcab103681743c1994484d3a65 to your computer and use it in GitHub Desktop.
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 code '(+ 2 (+ 3 4))) | |
(defn wrangle [code] | |
(loop [c code | |
newc '()] | |
(if (seq? (last c)) | |
(recur (last c) (conj newc (butlast c))) | |
(conj newc (butlast c) (last c) '->>)))) | |
; user=> (wrangle code) | |
; (->> 4 (+ 3) (+ 2)) | |
; user=> (def code '(inc (inc (* 4 5 (/ 6 2))))) | |
; #'user/code | |
; user=> (wrangle code) | |
; (->> 2 (/ 6) (* 4 5) (inc) (inc)) | |
; user=> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment