An equivalent implementation of the following code snippets in Scheme is available here.
- Implementation and validation of a mutable two-dimensional Point datatype.
[ Download ]
- Implementation of a datatype to define an expression- Exp :: = numExp(n: Number) | plusExp(operand1: Exp, operand2: Exp).
[ Download ]
- Tail Recursive and Iterative programs on lists. Implement a function which takes a list 'ls' and an value 'x' and checks whether x exists in ls.
[ Download ]
- A program that takes a function 'f' and a natural number 'n' as input and returns the nth iterate of f.
[ Download ]
- Design of the function - braid. Braid takes two lists ls1 and ls2 and returns a new list whose elements are alternately taken from ls1 and ls2. Elements remaining from the longer list after braiding are copied without change.
[ Download ]
- Implement a function that takes a list ls and an element x and returns a new list which is equivalent to the old list except that all occurrences of the element x are removed.
[ Download ]
- Recursively reverse the contents of a list.
[ Download ]
- Define functions listSum (and listProduct, respectively) recursively that sum (and multiply, respectively) all the elements of a list of numbers.
[ Download ]
- Define functions listEvery and listSome that takes a predicate p and a list ls, and returns #t if every (respectively, some) element of ls satisfies p, #f otherwise.
[ Download ]
- Define a recursive function 'listReduce' which takes a seed value 'a', binary function 'p', and a list 'ls' of values and reduces the list to a value according to the following pattern. listReduce(seed, p, [a, b, c]) = (p a (p b (p c seed))). In addition, use list-reduce to define the following functions described above - listSum, listProduct, listEvery and listSome.
[ Download ]