

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
Problem solutions in scheme programming language. It includes evaluating expressions, writing procedures for days to minutes and minutes to days conversions, computing the hypotenuse of a right triangle, writing xor logical operator, and writing recursive procedures for multiplication and even number check.
Typology: Exercises
1 / 3
This page cannot be seen from the preview
Don't miss anything!


The usual: type of expression, guess the value, then evaluate.
(lambda (x y z) x) ((lambda (x y) (+ x y)) 4 (+ 3 4)) ((lambda (happy tiger) (if (= tiger 4) (+ happy tiger) happy)) 4 5) ((lambda (wow this works) (wow this works))
(define x 2) ((lambda (x) (+ x x)) 5) ((lambda (yummy) (* yummy yummy)) 5) yummy
For each problem, write the specified procedure while obeying the given constraints on what primitive procedures are available. Additionally, test the procedure with a couple of inputs and include these test cases and their results in your submission to demonstrate that your procedure works.
(define seconds-per-minute 60.0) (define minutes-per-hour 60.0) (define hours-per-day 24.0) (define days-per-year 365.25) (days->minutes 1) ;Value: 1440. (minutes->days 1) ;Value: 0.
(define pythagoras (lambda (a b)
(define xor (lambda (x y)
(censor "I love scheme; it's so cool!") ;Value: "I love scheme; it's so cool!" (censor "Dunno, but I think scheme sucks") ;Value: "BEEP"
You may find the primitive procedure substring? handy.
(define censor (lambda (s)