Question: Scheme programming Question, I need to construct this function. partialsums* takes a list that may contain sublists. The output should have the same list structure
Scheme programming Question,
I need to construct this function.
partialsums* takes a list that may contain sublists. The output should have the same list structure as the input, but the car of each list (and each sublist) should be the sum of all numbers in that list. There should be no other values in the list. You can write this function without any helper functions.
Example output:
> (partialsums* '(1 a 2 b)) (3) > (partialsums* '((1) (2) (3))) (6 (1) (2) (3)) > (partialsums* '((1 2) (10 20) (100 200))) (333 (3) (30) (300)) > (partialsums* '(1 a (10 20 x y) c 2 (x y z) (a b 1 (c 200 d)))) (234 (30) (0) (201 (200)))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
