In the scheme, when a list is defined as ((item number a unit price a purchase number a) (item number b unit price b purchase number b) ...),
How should I describe the function to find the sum of the unit price of this number of purchases?
I know how to pass the list to the arguments of the function, but I don't know how to write how to take out the list and calculate the sum.
scheme
The following is how to use cadr
and apply
.
(define lst'((110010)(22505)(35003))))
(apply+(map cadrlst))
=>
850
© 2024 OneMinuteCode. All rights reserved.