SCHEME LANGUAGE
Suppose you are writing a Scheme program for a grocery storethat will calculate the total price of a customer’s items,represented as a list. Your partner suggests writing a seriesof Scheme forms like (define item price) then recursively goingthrough the list using those defines to calculate the sum as below. Will that work? If not, why not? What should becorrected?
(define milk 2.99)(define chicken 7.99)(define carrots 1.99)(define add-cart (lambda(x) (if (empty? x) 0 (+ (car x) (add-cart(cdr x))))))(add-cart '(milk chicken carrots))
SCHEME LANGUAGE Suppose you are writing a Scheme program for a grocery store that will calculate the total price of a cu
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
SCHEME LANGUAGE Suppose you are writing a Scheme program for a grocery store that will calculate the total price of a cu
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!