For example:
{defrecord Item [cost value]}
{def items [(Item. 20 50)
(Item. 30 40)
(Item. 10 70)]
How would I go about summing the cost of items? (so I'd get 60)
user=> (defrecord Item [cost value])
user.Item
user=> (def items [(Item. 20 50)
(Item. 30 40)
(Item. 10 70)])
#'user/items
user=> (reduce + (map :cost items))
60
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With