SCHEME LANGUAGE Scheme program for a grocery store that will calculate the total price of a customer’s items, represente
Posted: Thu Jul 14, 2022 2:18 pm
SCHEME LANGUAGE
Scheme program for a grocery store that will calculate the totalprice of a customer’s items, represented as a list. Recursively going through the list using those defines to calculatethe sum as below. Will that work and why? What should be corrected?
(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 program for a grocery store that will calculate the totalprice of a customer’s items, represented as a list. Recursively going through the list using those defines to calculatethe sum as below. Will that work and why? What should be corrected?
(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))