的名單我有兩個數據結構:結合地圖和矢量和列表
(def epics {"ARP-37" 8.0, "ARP-24" 5.0, "ARP-22" 13.0, "ARP-6" 21.0, "ARP-1" 8.0})
(def releases '(["Release one" '("ARP-37" "ARP-22" "ARP-6")]))
; gets the sum of a list of epics (maps epic keys to its corresponding story points)
(defn get-max-sp [epic-list] (reduce + (map #(get epics %) epic-list)))
(def initial-sp (get-max-sp '("ARP-37" "ARP-22" "ARP-6")))
有些人可能會認識到這是JIRA數據。不過,我想這兩個結構結合起來,看起來就像這樣:
; where (now) is a function from clj-time returning the current date
(def result [{x: (now), y: initial-sp }
{x: (+ now (get epics "ARP-37")), y: (- initial-sp (get epics "ARP-37))}
{x: (+ now (get epics "ARP-37") (get epics "ARP-22")),
y: (- initial-sp (get epics "ARP-37") (get epics "ARP-22"))}
{x: (+ now (get epics "ARP-37") (get epics "ARP-22")
(get epics "ARP-6")),
y: (- initial-sp (get epics "ARP-37") (get epics "ARP-22")
(get epics "ARP-6"))}
])
所以,在執行功能後,我想要的結果看起來像這樣:
[{x: 2014-02-18, y: 42}
{x: 2014-02-26, y: 34}
{x: 2014-03-11, y: 21}
{x: 2014-04-01, y: 0}
]
我有麻煩組合和映射兩種結構得到我的結果,我很想得到關於如何處理這個問題Clojure中:-)
感謝一些提示, 斯文
更新:因爲它似乎不清楚x和y應該是什麼,我會試着解釋他們多一點。 x應該是一個具有今天初始值的日期,並且在每個迭代步驟中,史詩的故事點將被添加到它中。「ARP-37」是史詩和8.0的故事點。 和是類似的,它開始於史詩列表的所有故事點的一些,然後在每個迭代步驟下降其史詩故事點的數量。 迭代將在史詩列表上。
這很漂亮:-)我不知道減少功能,感謝你的洞察力。 – sveri