Skip to content

Instantly share code, notes, and snippets.

@chrisatfundingcircle
Created May 29, 2019 15:29
Show Gist options
  • Save chrisatfundingcircle/3acfc335366ddeb61d850e5e74fae6d6 to your computer and use it in GitHub Desktop.
Save chrisatfundingcircle/3acfc335366ddeb61d850e5e74fae6d6 to your computer and use it in GitHub Desktop.
(defn add-statuses [instalments effective-date]
(map (fn [current previous]
(assoc current :status (cond
(<= (:due-date current) effective-date) :due
(<= (:due-date previous) effective-date) :open
:else :scheduled)))
(partition 2 1 (concat [{:due-date 0}] instalments))))
vs
(defn add-statuses [instalments effective-date]
(map (fn [current previous]
(assoc current :status (cond
(<= (:due-date current) effective-date) :due
(<= (:due-date previous) effective-date) :open
:else :scheduled)))
instalments
(concat [{:due-date 0}] instalments )))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment