Lisp Quiz Preparation Sheet

 

What will be returned by each of the following?

 

 

  1. (car ‘(( 3 5) 2 ( 4 6)))

 

 

  1. (* (/ 15 3) (- 7 2))

 

 

  1. (/ 17 2)

 

  1. (+ (truncate (/ 17 2)) 5)

 

 

  1. (setq a ‘(1 2 3 4))

(setq b (car a))

 

Given the 2 statements above,  which of the following statements will produce the following list which has the 2nd and 4th elements interchanged (1 4 3 2)

 

(append b (reverse (cdr a)))

 

(cons b (reverse (cdr a)))

 

(list b  (reverse (cdr a)))

 

Will any of them work for a longer original list such as (1 2 3 4 5 6 7)?

 

  1. What will be returned by

 

(not nil)

 

          (or ())

 

(or ‘(t nil))

 

(or 3 4 5)

(and  3 4 5)

 

(and t nil 7)

 

(or  t nil 7)

 

7.  (atom ‘Mary)

 

 

  1. (max ‘2 23 -12 76 32)

 

  1. (equal  5  (+ 2 3))

 

  1. (length ‘(apple  berry cherry dragonFruit))

 

  1. (subst  ‘easy ‘hard ‘(Lisp is hard and pascal is easy ))

 

  1. (member ‘a ‘(a b c))

 

  1. (mapcar ‘oddp ‘(1 2 3))

 

  1. (apply ‘+ ‘( 1 2 3))

 

  1. (reverse ‘(berry cherry apple  orange))

 

     ( defun  mystery (a b)

         (cond 

                ((> a b) a)

                 (( > b a ) b)

                (t  (* (+ b b) (+ a a)))

        )

    )

 

       Given the function mystery above,  what will be returned by

          (mystery 2 3)

          (mystery 7 -12)

          (mystery 5 5)