Please Help me add up the elements for this structure in Scheme/Lisp
- by kunjaan
I have an input which is of this form:
(((lady-in-water . 1.25) (snake . 1.75) (run . 2.25) (just-my-luck . 1.5))
((lady-in-water . 0.8235294117647058) (snake . 0.5882352941176471) (just-my-luck . 0.8235294117647058))
((lady-in-water . 0.8888888888888888) (snake . 1.5555555555555554) (just-my-luck . 1.3333333333333333)))
(context: the word denotes a movie and the number denotes the weighted rating submitted by the user)
I need to add all the quantity and return a list which looks something like this
((lady-in-water 2.5)
(snake 2.5)
(run 2.25)
(just-myluck 2.6))
How do I traverse the list and all the quantities? I am really stumped. Please help me.
Thanks.