Skip to content

Instantly share code, notes, and snippets.

Created November 21, 2014 13:22
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 anonymous/0654ae82e81724b1ca2b to your computer and use it in GitHub Desktop.
Save anonymous/0654ae82e81724b1ca2b to your computer and use it in GitHub Desktop.
;; merge adjacents: sum values for in-/out-of-order, ditch extra cols and add sum-of-OOO values
(defn merge-set [xs]
(concat (vec (take 3 (first xs)))
(if (second xs)
[(sum-nths 4 xs) (sum-nths 4 (filter #(nth % 3) xs))]
[(nth (first xs) 4) 0])))
(defn normalize-updated-labels [rows]
(->> rows
(map update-label-order)
(sort)
(partition-by (partial take 3))
(map merge-set)
(concat)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment