Due in Lecture Feb 10. Except for the Parameter Passing question (question 4), these Scheme functions must all be written in a pure functional style (no side effects).
To turn in your work, please put all of your functions, using the names specified in the homework, in a single file called 'homework4.scm'. Make a separate text file with the output of your tests with clear headings for the output from the different functions. Use the following turnin command to turn the file in electronically:
turnin homework4.scm homework4-output.txtDo not zip or tar the files before turning them in. To check that the turnin was successful, use turnin -v
See the 341 homework submission guidelines for general information, and for tips about how to capture the output from Scheme to turn in.
Hints: look at the lecture notes for examples in other languages that behave differently under different parameter passing mechanisms. You can assign into a function's parameter in Scheme (although it is very bad style - so only do this to prove your point here, and not anywhere else). For example:
(define (test x) (display "x = ") (display x) (newline) (set! x '(elmer fudd)) (display "after the set! x = ") (display x) (newline))If you want to use the eq? function in proving your point, use a list as the argument you're passing -- eq? applied to numbers may have unexpected behavior.
Other functions that you could use to prove your point are set-car! and set-cdr! that do list surgery. (These are even more evil than set!, so don't use them except for this question.) For example, try this code in an interactive session, and see what happens to x after each statement:
(define x '(john paul george ringo)) (set-car! x 'elvis) (set-cdr! x ())