Some Scheme vs Lisp help:

 

The basic syntax of these two languages is incredibly close.  Generally, Scheme’s (define (lambda (... gets replaced Lisp’s (defun (..., with each being followed by the parameters for the function, then the body.  (One less paren, total, on the end of the Lisp expression.)

 

Within these examples, you’ll spot a few other slight differences -- Like Scheme uses “null?” while Lisp uses “not” and Scheme uses “odd?” while Lisp uses “oddp”.  These are largely things you can try, and when they don’t work in Lisp, look up the similar Lisp function.

 

Consider the example given to try in the HW 4 assignment – a function to calculate list length --

 

In Scheme:

 

(define list-length

  (lambda (l)

    (cond ((null? l) 0)

              (else (+ 1

                           (list-length (cdr l)))))))

 

In Lisp:

 

(defun list-length-2

   (l)

    (cond ((not l) 0)

        (t (+ 1

               (list-length-2 (cdr l))))))

 

So  (list-length-2 '(a b c))  =>  3

 

---------------------------------------------------------------------

 

Here’s problem 2 from HW 1 -- replace values --

 

In Scheme:

 

(define replace

  (lambda (x y ls)

    (if (null? ls)

        ls

        (if (equal? x (car ls))

            (cons y (replace x y (cdr ls)))

            (cons (car ls) (replace x y (cdr ls)))))))

 

In Lisp

 

(defun replace-2 (x y ls)

    (if (not ls)

        ls

        (if (equal x (car ls))

            (cons y (replace-2 x y (cdr ls)))

            (cons (car ls) (replace-2 x y (cdr ls))))))

 

So,  (replace-2 'a 'b '(a b c d e f g b a)) => (b b c d e f g b b)

And  (replace-2 'a 'b '(b c d e)) => (b c d e)

 

---------------------------------------------------------

 

Here’s the odd list length test (HW 1 problem 1):

 

In Scheme:

 

(define l-l-o?-hlp

  (lambda (x y)

    (if (null? x)

        (odd? y)

        (l-l-o?-hlp (cdr x) (+ y 1)))))

 

(define list-length-odd?

  (lambda (x)

    (l-l-o?-hlp x 0)))

 

In Lisp

 

(defun l-l-o-hlp (x y)

    (if (not x)

        (oddp y)

        (l-l-o-hlp (cdr x) (+ y 1))))

 

(defun list-length-odd (x)

    (l-l-o-hlp x 0))

 

So  (list-length-odd '(a b)) => nil

And  (list-length-odd '(a b c)) => T

And  (list-length-odd '()) => nil