COSC 3410 Programming Languages

Homework Assignment #1

A Gentle Introduction to Scheme
Submit: Turn in a single Scheme source file called "hw1.scm" using the turnin command on the Systems Lab machines. Work is to be completed individually. Your source file should be in the EoPL dialect ("#lang eopl" at top of file) supported by DrRacket, and should not make use of non-standard features like comment boxes that produce an XML file rather than a flat text .scm file.

Q1 - append-item

Define a function "append-item" which takes an S-expression and a list, and returns a new list with the S-expression appended at the end. Do not use the built-in append.
Examples:
> (append-item 'a '())
(a)
> (append-item 'e '(a b c d))
(a b c d e)

Q2 - append-list

Define a function "append-list" which takes two lists and returns a new list with the contents of the first list followed by the contents of the second.
Examples:
> (append-list '(a b) '(c d))
(a b c d)
> (append-list '() '())
()

Q3 - rotate-list

Define a function "rotate-list" which takes a list a returns a new list with the first S-expression now at the end of the list.
Examples:
> (rotate-list '(a b c d e))
(b c d e a)

Q4 - rotate-list-n

Define a function "rotate-list-n" which takes a list and an integer n, and returns a new list which has been rotated n times.
Examples:
> (rotate-list-n '(a b c d e) 2)
(c d e a b)

Q5 - remove

EoPL Exercise 1.9.

Q6 - invert

EoPL Exercise 1.16.