

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Please attempt these problems by yourself. If you get stuck and need assistance, talk to the course staff.
(with-tax 5.00) ;Value: 5. (with-tax 259.99) ;Value: 272.
Remember that you can't actually use the $ in your code or it won't work.
(num-digits 5) ;Value: 1 (num-digits 21) ;Value: 2 (num-digits 3987423) ;Value: 7
You will find quotient useful, as it works like /, except it throws away anything after the decimal point (ie integer division). For example:
(quotient 4 2) ;Value: 2 (quotient 5 2) ;Value: 2
First write out a plan (base case and recursive case), then implement the procedure in scheme. Finally, test your procedure to verify that it works.
(add-digit 123 4) ;Value: 1234 (add-digit 7 1) ;Value: 71
You may collaborate on these problems.
(divisible? 6 3) ;Value: #t (divisible? 37 4) ;Value: #f
(inc 5) ;Value: 6 (dec 3) ;Value: 2 (zero? 0) ;Value: #t (slow-add 5 3) ;Value: 8
These problems are sticky. Make sure you have a good plan before you go for implementation.