LISP


LISP Expressions

Q. Write the value of each of the following LISP expressions: (Dec. 98)

  1. (member 'c '(d e c f g))
  2. (+ 5 6)
  3. (cdr '((a b) (c d e)))
  4. (greaterp 8 15 72)

Ans.

  1. (C F G)
  2. 11
  3. ((C D E))
  4. T

Q. Evaluate the following LISP expressions: (June 99)

  1. (lessp 5 3 2 1)
  2. (append '(3 a b) '(4 7 8))
  3. (last '(a b (c d e))
  4. (print "Good Morning")
  5. (putprop 'car 'ford 'make)

Ans.

  1. T
  2. (3 A B 4 7 8)
  3. ((C D E))
  4. "Good Morning"
  5. FORD

Q. Evaluate the following LISP expressions: (Dec. 99)

  1. (member 'd '(a (d) (e f)))
  2. (reverse '(a (b c) (d e)))
  3. (lessp 5 3 12)
  4. (or (and (atom x) (equal 'a x))
    (and (not (atom x)) (atom (car x))))

Ans.

  1. NIL
  2. ((D E) (B C) A)
  3. NIL
  4. T

Q. Evaluate the following LISP expressions: (Dec. 00)

  1. (+ 7 3 5 9)
  2. (member 'p '(a b p c d))
  3. (setq x 10)
  4. (cons (+ 2 3) '1)
  5. (append '((a b) c) '((d) (e f)))

Ans.

  1. 24
  2. (P C D)
  3. 10
  4. (5 1)
  5. ((A B) C (D) (E F))

Q. Evaluate the following LISP expressions: (Jan. 01)

  1. (append '((a)) '(b c))
  2. (print "hellow there")
  3. (defun nonsense () (terpi))

Ans.

  1. ((A) B C)
  2. "hellow there"
  3. NONSENSE

Q. Evaluate the following LISP expressions: (June. 01)

  1. (greaterp 18 151 76) (June. 03)
  2. (reverse '((p q) r (s t))) (June. 03)
  3. (+ (* (/ 9 5) 50) 32)

Ans.

  1. NIL
  2. ((S T) R (P Q))
  3. 122

Q. Evaluate the following LISP expressions: (Dec. 01)

  1. (greaterp 57 75 105)
  2. (mapcar '+ '(2 4 6 8 10) '(1 2 3 4))
  3. (setq y '(a b 15))

Ans.

  1. T
  2. (3 6 9 12)
  3. (A B 15)

Q. Evaluate the following LISP expressions: (June 02)

  1. (lessp 45 40 76)
  2. (* (+ 9 5) (* (/ 10 3) 5))
  3. (defun factorial (n)
    (cond (((zerop n) 1)
    (t (* n (factorial (n 1))))))

Ans.

  1. NIL
  2. 233.33
  3. FACTORIAL

Q. Evaluate the following LISP expressions: (Dec. 02)

  1. (member 'x '(y (x) (z u)))
  2. (setq s '(p q r))
  3. (reverse '((a b) c (d h)))

Ans.

  1. NIL
  2. (P Q R)
  3. ((D H) C (A B))
 
          AI Contents  
©Universal Teacher Publications Web: www.universalteacherpublications.com.