

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A collection of problem-solving exercises in scheme programming language. The exercises cover various types of procedures, including tax calculation, decimal digits, number addition, and divisibility. Some problems can be solved collaboratively, while others require individual effort. The document also includes suggestions for implementing certain procedures and provides examples of expected outputs.
Typology: Exercises
1 / 3
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.