Skip to content

Instantly share code, notes, and snippets.

@joe-crick
Last active September 7, 2018 12:44
Show Gist options
  • Save joe-crick/48bf27b01b712d359dc2a9b37818c67c to your computer and use it in GitHub Desktop.
Save joe-crick/48bf27b01b712d359dc2a9b37818c67c to your computer and use it in GitHub Desktop.
;; with parens
(defn symmetrize-body-parts
"Expects a seq of maps that have a :name and :size"
[asym-body-parts]
(loop [remaining-asym-parts asym-body-parts
final-body-parts []]
(if (empty? remaining-asym-parts)
final-body-parts
(let [[part & remaining] remaining-asym-parts]
(recur remaining
(into final-body-parts
(set [part (matching-part part)])))))))
;; without parens
defn symmetrize-body-parts
"Expects a seq of maps that have a :name and :size"
[asym-body-parts]
loop [remaining-asym-parts asym-body-parts
final-body-parts []]
if empty? remaining-asym-parts
final-body-parts
let [[part & remaining] remaining-asym-parts]
recur remaining
into final-body-parts
set [part matching-part part]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment