Last active
February 27, 2019 18:32
-
-
Save eneroth/745c65385ee21eedc6322ea741d259da to your computer and use it in GitHub Desktop.
Flips attributes around
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 flip-attrs [attributes] | |
(let [one (clojure.string/split attributes #"&") | |
two (map #(clojure.string/split % #"=") one) | |
three (map reverse two) | |
four (map #(interpose "=" %) three) | |
five (interpose "&" four) | |
six (flatten five)] | |
(apply str six))) | |
(flip-attrs "tool=whip&clothing=hat&sidearm=pistol") | |
;; => "whip=tool&hat=clothing&pistol=sidearm" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment