## CSci 4651 Programming languages -- Assignments.

[Home] [Syllabus] [Assignments] [Resources]

This page contains problem set assignments for the course. The assignments will be added as they become available.

### Lab assignments

• Lab 1. Define and test the following Scheme functions:
1. `swap` takes a single argument. If it is an atom (i.e. not a pair), it just returns the argument. If it's a pair, it switches the car and the cdr. For instance:
``````
(swap (cons 5 8))
>(8 . 5)
(swap '(2 3 4))
>((3 4) . 2)   ; Why?
(swap 5)
> 5
``````
2. `deep-swap` is a recursive version of swap: it recursively swaps all cons-cells in the arguments. Test this function carefully. What happens if it's applied to a list? Guess what happens when it's applied as follows:
``````
(define x (cons 3 4))
(define y (cons x x))
(deep-swap y)
``````
Now try it. Is that what you expected? Can you explain the results?
3. Type in the following definition:
``````
(define z (cons + '(2 3)))
``````
What is z? Test it. How can we get the result of the expression, given z?
• Lab on generics
• Lab on C++
• Lab on Java bytecode

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.