0% found this document useful (0 votes)
7 views12 pages

Ai Manuals

Uploaded by

ambikajaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views12 pages

Ai Manuals

Uploaded by

ambikajaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Practical 1

Aim: Introduction to Lisp

Description:
Lisp is one of the oldest programming language. It was invented by John
Mcarthy,during the late 1950s .Lisp is particularly suited for AI programmes
because of its syntax.

Basic building blocks of Lisp are:

Atom

List

String.

Conclusion:
Thus we have studied the Lisp .
Practical 2
Aim: Write a lisp code for illustrating basic list related functions.
Description:
Representation of valid atom, valid string and valid list,list manipulating
functions.
 Car: car takes one argument, a list and returns first element.

 Cdr: cdr takes one argument, a list returns alist with the first element
removed.

 Cons: cons take two argument, an element an a list and returns a list
with the element inserted at the beginning.

 List: list takes any number of argument and returns a list with the
argument as element.

 Append: append merges argument of one or more list into a single


list.

 Last: last takes one argument a list contain the last element.

 Member: member takes two argument , a second of which must be


list. If the first argument is a member of second is returned
beginning with the member element.

 Reverse: reverse takes list as its argument and returns a list with the
top element in reverse order from the input list.

Conclusion:
Thus we have illustrated basic list functions.
Practical 3
Aim: Write a lisp code for calculating following parameters using formulae.

Description:
Parameters
 Area of circle.:Function used-defun,setq,terpri.

 square of a number.:Function used-defun,setq.

 circumference of a circle. .:Function used-defun,setq,terpri.

 converting centigrade to Fahrenheit. .:Function used-defun,setq,terpri.

 converting Fahrenheit to centigrade. .:Function used-setq.

 finding area of a triangle. .:Function used-defun,setq.

 finding perimeter of a triangle. .:Function used-defun,setq,terpri

 Simple interest. .:Function used-defun,setq,terpri.

Conclusion:
Thus we have calculated above terms using lisp.
Practical 4
Aim: Write a lisp code for calculating following Operations.
1) average of numbers and
2) calculate whether the given number is ever or odd,

Description:
Average:
 finding average of three numbers: Function used-defun,setq.

(/ +(a b c) 3))

 finding average of n numbers.Function used-defun,setq.

(average of number= n1+n2+n3………..+nm/m)

Conclusion:
Thus we have calculated above Operation using lisp.
Practical 5
Aim: Write a lisp code for calculating Maximum and Minimum of Numbers.

Description:
1) findingmaximum of two numbers.

MAXMUM2
>(maximum2 4 5)
5

2) finding of maximum of three number.

MAXMUM3
>(maximum3 4 5 6)
6

3) finding of maximum of four number

MAXMUM4
>(maximum3 2 3 4 5)
5

Conclusion:
Thus we have calculated minimum and maximum of numbers using lisp.
Practical 6
Aim: Write a lisp code for Operations like Recursion ,Iteration , and .

Description:
1) finding factorial using recursion.

FACTORIAL2

>(factorial2 4)

24

2) Finding factorial using iteration.

>(factorial 6)

720

3) find sum of n numbers. (using iteration)

>(sumn 5)

15

4) find value of exponential (an) using iteration.

>(i 2 2)

Conclusion:
Thus we have executed recursion and iteration with lisp.
Practical 7
Aim: Write a lisp code for following functions.

Description:
1) setq function:
setq takes two argument ,the first of which must be a variable. It is
never evaluatedand should not be in quotation marks.
theseond argument is evaluated and the result is bpund to the first
argument.

2) logical function.
Like predicate, logical function may be used for flow of comtrol,
the basic logical operations are OR and NOT. It takes one
argument.

3) 6 Input / Output functions.


read,print,prinl,princ,terpri,format.

Conclusion:
Thus we have executed the above functions.
Practical 8
Aim: Introduction to prolog.

Description:
The name prolog was taken from phrase programming logic, the language
was originally developed in 1972 by “A Win Clomeraquas and a D Rausel”.

Prolog is unique in ability to interdevice by formal reasoning , fact and


conclusion from other in solving a problem is logical concern and formal
manner presenting fact and knowledge about the problem and specifying a
goal.

Conclusion:
Thus we studied prolog.
Practical 9
Aim: Write a program to calculate following Parameters

Description:
1) area and circumference of a circle: function used –calc
area = 3.14*radius*radius
cicum=2*3.14*radius

2) area and perimeter of a triangle:function used-area_tri,perimeter


area_tri(Base,height)
perimeter(side1+side2+base)

3) root of quadratic equation:function used-greatest


greatest(read,read,read)

Conclusion:
Thus we calculated above parameters prolog.
Practical 10
Aim: Write a program to Perform following operation on list in prolog

Description:
1) count number of elements in list:function used-count

2) find sum of element in a list.function used-sum

3) Search element in a list: function used-find

4) find the last number in a list:function used-last

5) delete last number in a list.function used-del

6) to append two given list.function used-con

7) to check two list where equal or not.function used-equal

8)to find largest of given list.function used-maxno

Conclusion:
Thus we performed above operations on list.
Practical 11
Aim: Write a program to Perform following operation on following types of
equation in prolog

Description:

1) to find out root of quadratic equation.

D=sqrt((b*b)-(4*a*c)

R1=((c-b+d)/2*a)

R2=((c-b-d)/2*a)

Conclusion:
Thus we performed above operations in prolog.
Practical 12
Aim: Write a program to Perform following in prolog.

Description:
1) perform basic functions of calculator
add(read,read)
diff(read,read)
mul(read,read)
div(read,read)

2) implement expert system for PC trouble shooting.

Read int(R)
Trouble(R),n1
Trouble(k)……>

3) to implement medical diagnosis system.


Reading(R)
Disease(r)

Conclusion:
Thus we performed above operations in prolog.

You might also like