|
LISP Expressions
Q. Write the value of each of the following LISP expressions:
(Dec. 98)
- (member 'c '(d e c f g))
- (+ 5 6)
- (cdr '((a b) (c d e)))
- (greaterp 8 15 72)
Ans.
- (C F G)
- 11
- ((C D E))
- T
Q. Evaluate the following LISP expressions: (June 99)
- (lessp 5 3 2 1)
- (append '(3 a b) '(4 7 8))
- (last '(a b (c d e))
- (print "Good Morning")
- (putprop 'car 'ford 'make)
Ans.
- T
- (3 A B 4 7 8)
- ((C D E))
- "Good Morning"
- FORD
Q. Evaluate the following LISP expressions: (Dec. 99)
- (member 'd '(a (d) (e f)))
- (reverse '(a (b c) (d e)))
- (lessp 5 3 12)
- (or (and (atom x) (equal 'a x))
(and (not (atom x)) (atom (car x))))
Ans.
- NIL
- ((D E) (B C) A)
- NIL
- T
Q. Evaluate the following LISP expressions: (Dec. 00)
- (+ 7 3 5 9)
- (member 'p '(a b p c d))
- (setq x 10)
- (cons (+ 2 3) '1)
- (append '((a b) c) '((d) (e f)))
Ans.
- 24
- (P C D)
- 10
- (5 1)
- ((A B) C (D) (E F))
Q. Evaluate the following LISP expressions: (Jan. 01)
- (append '((a)) '(b c))
- (print "hellow there")
- (defun nonsense () (terpi))
Ans.
- ((A) B C)
- "hellow there"
- NONSENSE
Q. Evaluate the following LISP expressions: (June. 01)
- (greaterp 18 151 76) (June. 03)
- (reverse '((p q) r (s t))) (June. 03)
- (+ (* (/ 9 5) 50) 32)
Ans.
- NIL
- ((S T) R (P Q))
- 122
Q. Evaluate the following LISP expressions: (Dec. 01)
- (greaterp 57 75 105)
- (mapcar '+ '(2 4 6 8 10) '(1 2 3 4))
- (setq y '(a b 15))
Ans.
- T
- (3 6 9 12)
- (A B 15)
Q. Evaluate the following LISP expressions: (June 02)
- (lessp 45 40 76)
- (* (+ 9 5) (* (/ 10 3) 5))
- (defun factorial (n)
(cond (((zerop n) 1)
(t (* n (factorial (n 1))))))
Ans.
- NIL
- 233.33
- FACTORIAL
Q. Evaluate the following LISP expressions: (Dec. 02)
- (member 'x '(y (x) (z u)))
- (setq s '(p q r))
- (reverse '((a b) c (d h)))
Ans.
- NIL
- (P Q R)
- ((D H) C (A B))
|
|