Description
Problem I { Scheme
Write Scheme programs that generate the following lists as output using only cons as the list building operator:

‘((c (e f (b))) g b)

‘((g) ((((h) i)) (a f)) d)

A list l that contains three items: the atom ’g’, the division operator ’/’, and the atom ’6’ such that ((cadr l) 18 9) evaluates to 2.
Note that cadr is composed of car and cdr such that (cadr l) = (car (cdr l)).
Problem II { Scheme
Write the following functions on lists in Scheme. The semantics of the functions is described through examples.
1. Get nth digit of an integer
(define getnthdigit
(lambda (m n)
…))
…
(getnthdigit 32145 1) –> 5
(getnthdigit 32145 2) –> 4
Note: You can use Scheme buildin function “modulo” and ” oor”.
1

(define rev (lambda (l)
…))
…
(rev ‘(e((b)(c d)(((f)))))) –> ‘(((((f)))(d c)(b))e)
Note: Do not use the Scheme buildin function “reverse”.
3. Position of rst occurrence of k in list
(define positionof
(lambda (k lst)
…))
…
(positionof ‘c ‘(c b d c e f)) –> 1
Note: You may want to de ne a helper function
2