【发布时间】:2014-02-18 21:37:54
【问题描述】:
我有两个数据结构:
(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 是它的故事点。 y 是类似的,因为它从史诗列表的所有故事点开始,然后在每个迭代步骤中下降其史诗的故事点数。 迭代将超过史诗列表。
【问题讨论】: