Lisp Lab Manual
Lisp Lab Manual
LISP
List of Experiments
6. Define a Recursive LISP function which takes one argument as a list and returns a list
except last element of the list. (Do not use but last predicate).
7. Define a Recursive LISP function which takes one argument as a list and returns reverse of
8. Define a Recursive LISP function which takes two arguments first, an atom, second, a list,
returns a list after.
LAB OBJECTIVE
Advance Programming
Lisp is a family of computer programming languages with a long history and a distinctive, fully
Lisp was originally created as a practical mathematical notation for computer programs, influenced
by the notation of Alonzo Church's lambda calculus. It quickly became the favored programming
language for artificial intelligence (AI) research. As one of the earliest programming languages,
Lisp pioneered many ideas in computer science, including tree data structures, automatic storage
management, dynamic typing, conditionals, higher-order functions, recursion, and the self-
hosting compiler.
Lisp was closely connected with the artificial intelligence research community,
Lisp was used as the implementation of the programming language Micro Planner which
Equipment in the lab for the use of student community. Students need to maintain a proper
decorum in the computer lab. Students must use the equipment with care. Any damage is caused
is punishable.
Students are required to carry their observation / programs book with completed exercises while
entering the lab.
Students are supposed to occupy the machines allotted to them and are not supposed to talk or
make noise in the lab. The allocation is put up on the lab notice board.
Lab can be used in free time / lunch hours by the students who need to use the systems should
take prior permission from the lab in-charge.
(defun sumsqr (x y)
(+(* x x)(* y y)))
OUTPUT :
sumsqr
13
Experiment 2
Define a LISP function to compute differance of squares .(if x > y return x2– y2 ,
Otherwise y2 – x2 )
(defun diffsqr (x y)
(if(> x y)
(-(* x x) (* y y))
(-(* y y) (* x x))))
Write (diffsqr 2 3)
OUTPUT :
DIFFSQR
5
Experiment 3
Define a Recursive LISP function to solve Ackermann’s Function.
Write (ackermann 2 3 )
OUTPUT :
ACKERMANN
9
Experiment 4
Define a Recursive LISP function to compute the factorial of given number.
Write (factorial 5)
OUTPUT :
FACTORIAL
120
Experiment 5
Define a Recursive LISP function which takes one argument as a list and return last element of
The list.(do not use last predicate.)
(defun last_element(ab_list)
(first(reverse ab_list)))
OUTPUT :
LAST_ELEMENT
D
Experiment 6
Define a Recursive LISP function which takes one argument as a list and return list except last
element of the list.(do not use butlast.)
(defun not_last(ab_list)
(reverse(rest(reverse ab_list))))
OUTPUT :
NOT_LAST
(A B C D)
Experiment 7
Define a Recursive LISP function which takes one argument as a list and return reverse of the
list. (do not use reverse predicate).
OUTPUT :
LIST-APPEND
SHOW-LIST-REVERSE
(4 3 2 1)
Experiment 8
Define a Recursive LISP function which takes two argument first an atom second a list returns
a list after removing first occurrence of that atom within the list.
OUTPUT :
REMOVE
(1 2 3 4 4)