SlideShare ist ein Scribd-Unternehmen logo
1 von 43
ARTIFICIAL INTELLIGENCE
LISP and PROLOG
Submitted to : Submitted by:
Dr.arpana chaturvedi Arti kumari
S No. CONTENT REMARK
LISP
1 To print “hello world” in LISP
2 program To find the area of circle
3 to print odd number form 1-20
4 to print the average of number 10,20,30,40
5 defining macro
OPERATORS
6 Arithmetic operator
7 Comparision operator
8 Logical operator
DECISIONS CONSTRUCT
9 Cond
10 If
11 When
12 case
LOOPS
13 Loop
14 Loop for
15 Do
16 dotimes
17 dolist
18 Predicate
29 Factorial of a number
20 Array
21 String
22 Sequence
23 list
24 Exiting from block
25 Let function
26 Prog function
27 Formatted output
PROLOG
28 Print hello world using prolog. In console
29 prolog program to print hello world..
30 Priya, Tiyasha, and Jaya are three girls, among
them, Priya can cook
31 some rules. Rules contain some information that
are conditionally true about the domain of
interest.
32 Priya, Tiyasha, and Jaya are three girls, among
them, Priya can cook.
;use of variable in our query
33 Prolog program, that can find the minimum of
two numbers and the maximum of two numbers.
34 write a prolog program that will help us find the
equivalent resistance
35 program to show working of Arithmetic operator
in prolog
36 prolog program to print values from 1 to10 using
loop
37 Example of decision making in Prolog.
38 prolog program to find the length of the list
39 prolog program to concatenate two list
40 Backtracking.
41 prolog program to find the cube of a number
LISP
Q1)To print “hello world” in LISP
CODE:
(write-line "Hello World")
(write-line "I am at 'Online class' !-
Learning LISP" )
Q2) LISP program To find the area of circle ..
CODE:
(defconstantp13.141592)
(defunarea-circle(rad)
(terpri)
(formatt " Radius:~5f"rad)
(formatt "~%area:~10f" (* p1 rad rad)))
(area-circle 10)
Q3)LISP program to print odd number form 1-20 ?
CODE:
(loopfor x from 1 to 20
if(oddpx)
do (printx)
)
Q4)LISP program to print the average of number 10,20,30,40
CODE:
;write a LISP program to find the average of numbers
(defunaveragenum(n1 n2 n3 n4)
( / ( + n1 n2 n3 n4) 4)
)
(write(averagenum10 20 30 40))
Q5.defining macro
CODE:
(defmacro setTo10(num)
(setq num 10)(print num))
(setq x 25)
(print x)
(setTo10 x)
Q6)Arithmetic operators
(setq a 10)
(setq b 20)
(format t "~% A + B = ~d" (+ a b))
(format t "~% A - B = ~d" (- a b))
(format t "~% A x B = ~d" (* a b))
(format t "~% B / A = ~d" (/ b a))
(format t "~% Increment A by 3 = ~d" (incf a 3))
(format t "~% Decrement A by 4 = ~d" (decf a 4))
Q7) Comparison operator
(setq a 10)
(setq b 20)
(format t "~% A = B is ~a" (= a b))
(format t "~% A /= B is ~a" (/= a b))
(format t "~% A > B is ~a" (> a b))
(format t "~% A < B is ~a" (< a b))
(format t "~% A >= B is ~a" (>= a b))
(format t "~% A <= B is ~a" (<= a b))
(format t "~% Max of A and B is ~d" (max a b))
(format t "~% Min of A and B is ~d" (min a b))
Q8) logical operator
(setq a 10)
(setq b 20)
(format t "~% A and B is ~a" (and a b))
(format t "~% A or B is ~a" (or a b))
(format t "~% not A is ~a" (not a))
(terpri)
(setq a nil)
(setq b 5)
(format t "~% A and B is ~a" (and a b))
(format t "~% A or B is ~a" (or a b))
(format t "~% not A is ~a" (not a))
(terpri)
(setq a nil)
(setq b 0)
(format t "~% A and B is ~a" (and a b))
(format t "~% A or B is ~a" (or a b))
(format t "~% not A is ~a" (not a))
(terpri)
(setq a 10)
(setq b 0)
(setq c 30)
(setq d 40)
(format t "~% Result of and operation on 10, 0, 30, 40 is ~a"
(and a b c d))
(format t "~% Result of and operation on 10, 0, 30, 40 is ~a"
(or a b c d))
(terpri)
(setq a 10)
(setq b 20)
(setq c nil)
(setq d 40)
(format t "~% Result of and operation on 10, 20, nil, 40 is ~a"
(and a b c d))
(format t "~% Result of and operation on 10, 20, nil, 40 is ~a"
(or a b c d))
Q9) cond construct
(setq a 10)
(cond ((> a 20)
(format t "~% a is greater than 20"))
(t (format t "~% value of a is ~d " a)))
Q10) If construct
(setq a 10)
(if (> a 20)
(format t "~% a is less than 20"))
(format t "~% value of a is ~d " a)
Q11)When construct
(setq a 100)
(when (> a 20)
(format t "~% a is greater than 20"))
(format t "~% value of a is ~d " a)
Q12)Case construct
(setq day 4)
(case day
(1 (format t "~% Monday"))
(2 (format t "~% Tuesday"))
(3 (format t "~% Wednesday"))
(4 (format t "~% Thursday"))
(5 (format t "~% Friday"))
(6 (format t "~% Saturday"))
(7 (format t "~% Sunday")))
Q13)Loop construct
(setq a 10)
(loop
(setq a (+ a 1))
(write a)
(terpri)
(when (> a 17) (return a))
)
Q14)Loop for
(loop for x from 1 to 20
if(evenp x)
do (print x)
)
Q15)Do construct
(do ((x 0 (+ 2 x))
(y 20 ( - y 2)))
((= x y)(- x y))
(format t "~% x = ~d y = ~d" x y)
)
Q16)dotimes
(dotimes (n 11)
(print n) (prin1 (* n n))
)
Q17)dolist
(dolist (n '(1 2 3 4 5 6 7 8 9))
(format t "~% Number: ~d Square: ~d" n (* n n))
)
Q18)predicate
(write (atom 'abcd))
(terpri)
(write (equal 'a 'b))
(terpri)
(write (evenp 10))
(terpri)
(write (evenp 7 ))
(terpri)
(write (oddp 7 ))
(terpri)
(write (zerop 0.0000000001))
(terpri)
(write (eq 3 3.0 ))
(terpri)
(write (equal 3 3.0 ))
(terpri)
(write (null nil ))
Q19)To find the factorial of a number
(defun factorial (num)
(cond ((zerop num) 1)
(t ( * num (factorial (- num 1))))
)
)
(setq n 6)
(format t "~% Factorial ~d is: ~d" n (factorial n))
Q20)Array
(write (setf my-array (make-array '(10))))
(terpri)
(setf (aref my-array 0) 25)
(setf (aref my-array 1) 23)
(setf (aref my-array 2) 45)
(setf (aref my-array 3) 10)
(setf (aref my-array 4) 20)
(setf (aref my-array 5) 17)
(setf (aref my-array 6) 25)
(setf (aref my-array 7) 19)
(setf (aref my-array 8) 67)
(setf (aref my-array 9) 30)
(write my-array)
Q21)String
(write-line "Hello World")
(write-line "Welcome to JAGANNATH INSTITUTE OF MANAGEMENT
SCIENCES")
;escaping the double quote character
(write-line "Welcome SIXTH SEMESTER")
Q22) sequence
(write (count 7 '(1 5 6 7 8 9 2 7 3 4 5)))
(terpri)
(write (remove 5 '(1 5 6 7 8 9 2 7 3 4 5)))
(terpri)
(write (delete 5 '(1 5 6 7 8 9 2 7 3 4 5)))
(terpri)
(write (substitute 10 7 '(1 5 6 7 8 9 2 7 3 4 5)))
(terpri)
(write (find 7 '(1 5 6 7 8 9 2 7 3 4 5)))
(terpri)
(write (position 5 '(1 5 6 7 8 9 2 7 3 4 5)))
Q23)lists
(write (cons 1 2))
(terpri)
(write (cons 'a 'b))
(terpri)
(write (cons 1 nil))
(terpri)
(write (cons 1 (cons 2 nil)))
(terpri)
(write (cons 1 (cons 2 (cons 3 nil))))
(terpri)
(write (cons 'a (cons 'b (cons 'c nil))))
(terpri)
(write ( car (cons 'a (cons 'b (cons 'c nil)))))
(terpri)
(write ( cdr (cons 'a (cons 'b (cons 'c nil)))))
Q24)exiting from the block
Q25) let function
(let((x 'a)(y'b) (z'c))
(formatt "x= ~a y= ~a z= ~a" x y z))
Q26)prog function
(prog((x'(abc))(y'(12 3))(z'(pq10)))
(formatt"x=~a y=~a z=~a" x y z))
Q27)Formatted output
(setqx 10)
(setqy20)
(formatt"x=~2d y=~2d ~%" x y)
(setqx 100)
(setqy200)
(formatt"x=~2d y=~2d" x y)
PROLOG
Q28) Print hello world using prolog..
CODE:
write('Hello World').
Q29)prolog program to print hello world..
CODE:
main :- write('This is sample Prolog program'),
write(' This program is written into hello_world.pl file').
Q30) Priya, Tiyasha,and Jaya are three girls, among them,Priya can cook.
CODE:
girl(priya).
girl(tiyasha).
girl(jaya).
can_cook(priya).
Q31) some rules. Rules contain some informationthat are conditionally true about the
domain of interest.
CODE:
sing_a_song(ananya).
listens_to_music(rohit).
listens_to_music(ananya):- sing_a_song(ananya).
happy(ananya):- sing_a_song(ananya).
happy(rohit) :- listens_to_music(rohit).
playes_guitar(rohit):- listens_to_music(rohit).
Q32) Priya, Tiyasha,and Jaya are three girls, among them,Priya can cook.
;use of variable in our query
CODE:
can_cook(priya).
can_cook(jaya).
can_cook(tiyasha).
likes(priya,jaya) :- can_cook(jaya).
likes(priya,tiyasha) :- can_cook(tiyasha).
Q33) Prolog program,that can find the minimum of two numbers and the maximum
of two numbers.
CODE:
find_max(X,Y,X) :- X >= Y, !.
find_max(X,Y,Y) :- X < Y.
find_min(X,Y, X) :- X =< Y, !.
find_min(X,Y, Y) :- X > Y.
Q34) write a prolog program that will help us find the equivalent resistance.
 If R1 and R2 are in Series, then equivalent resistor Re = R1 + R2.
 If R1 and R2 are in Parallel, then equivalent resistor Re = (R1 * R2)/(R1 +
R2).
Q35)programto show working of Arithmetic operatorin prolog
+ Addition
- Subtraction
* Multiplication
/ Division
** Power
// Integer Division
mod Modulus
Q36)prolog program to print values from 1 to10 using loop
CODE:
count_to_10(10):- write(10),nl.
count_to_10(X) :-
write(X),nl,
Y is X + 1,
count_to_10(Y).
Q37) Example of decision making in Prolog.
CODE:
% If-Then-Else statement
gt(X,Y) :- X >= Y,write('X is greateror equal').
gt(X,Y) :- X < Y,write('X is smaller').
% If-Elif-Else statement
gte(X,Y) :- X > Y,write('X is greater').
gte(X,Y) :- X =:= Y,write('X and Y are same').
gte(X,Y) :- X < Y,write('X is smaller').
Q38)prolog program to find the length of the list ;?
CODE:
list_length([],0).
list_length([_|TAIL],N) :- list_length(TAIL,N1),N is N1 + 1.
Q39)prolog program to concatenatetwo list
CODE:
list_concat([],L,L).
list_concat([X1|L1],L2,[X1|L3]) :- list_concat(L1,L2,L3).
Q40)Backtracking.
CODE:
boy(tom).
boy(bob).
girl(alice).
girl(lili).
pay(X,Y) :- boy(X), girl(Y).
Q41)prolog program to find the cube of a number
CODE:
cube :-
write('Write a number:'),
read(Number),
process(Number).
process(stop) :- !.
process(Number) :-
C is Number* Number* Number,
write('Cube of '),write(Number),write(': '),write(C),nl,cube.

Weitere ähnliche Inhalte

Was ist angesagt?

Linux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScITLinux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScITvignesh0009
 
Production system in ai
Production system in aiProduction system in ai
Production system in aisabin kafle
 
Little o and little omega
Little o and little omegaLittle o and little omega
Little o and little omegaRajesh K Shukla
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compilerAbha Damani
 
Predicate calculus
Predicate calculusPredicate calculus
Predicate calculusRajendran
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expressionvaluebound
 
Natural language processing
Natural language processingNatural language processing
Natural language processingYogendra Tamang
 
Introduction to Natural Language Processing
Introduction to Natural Language ProcessingIntroduction to Natural Language Processing
Introduction to Natural Language ProcessingPranav Gupta
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
 
Top down and botttom up Parsing
Top down     and botttom up ParsingTop down     and botttom up Parsing
Top down and botttom up ParsingGerwin Ocsena
 
اجابات البرولوج
اجابات البرولوجاجابات البرولوج
اجابات البرولوجAmmar Khalid
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expressionAnimesh Chaturvedi
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computationBipul Roy Bpl
 
Theory of Computation "Chapter 1, introduction"
Theory of Computation "Chapter 1, introduction"Theory of Computation "Chapter 1, introduction"
Theory of Computation "Chapter 1, introduction"Ra'Fat Al-Msie'deen
 
Unit IV UNCERTAINITY AND STATISTICAL REASONING in AI K.Sundar,AP/CSE,VEC
Unit IV UNCERTAINITY AND STATISTICAL REASONING in AI K.Sundar,AP/CSE,VECUnit IV UNCERTAINITY AND STATISTICAL REASONING in AI K.Sundar,AP/CSE,VEC
Unit IV UNCERTAINITY AND STATISTICAL REASONING in AI K.Sundar,AP/CSE,VECsundarKanagaraj1
 

Was ist angesagt? (20)

Linux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScITLinux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScIT
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Production system in ai
Production system in aiProduction system in ai
Production system in ai
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
NLP_KASHK:Minimum Edit Distance
NLP_KASHK:Minimum Edit DistanceNLP_KASHK:Minimum Edit Distance
NLP_KASHK:Minimum Edit Distance
 
Little o and little omega
Little o and little omegaLittle o and little omega
Little o and little omega
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Predicate calculus
Predicate calculusPredicate calculus
Predicate calculus
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Natural language processing
Natural language processingNatural language processing
Natural language processing
 
Introduction to Natural Language Processing
Introduction to Natural Language ProcessingIntroduction to Natural Language Processing
Introduction to Natural Language Processing
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Top down and botttom up Parsing
Top down     and botttom up ParsingTop down     and botttom up Parsing
Top down and botttom up Parsing
 
اجابات البرولوج
اجابات البرولوجاجابات البرولوج
اجابات البرولوج
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
Theory of Computation "Chapter 1, introduction"
Theory of Computation "Chapter 1, introduction"Theory of Computation "Chapter 1, introduction"
Theory of Computation "Chapter 1, introduction"
 
Unit IV UNCERTAINITY AND STATISTICAL REASONING in AI K.Sundar,AP/CSE,VEC
Unit IV UNCERTAINITY AND STATISTICAL REASONING in AI K.Sundar,AP/CSE,VECUnit IV UNCERTAINITY AND STATISTICAL REASONING in AI K.Sundar,AP/CSE,VEC
Unit IV UNCERTAINITY AND STATISTICAL REASONING in AI K.Sundar,AP/CSE,VEC
 

Ähnlich wie Lisp and prolog in artificial intelligence

Class 10: Abstracting Procedures
Class 10: Abstracting ProceduresClass 10: Abstracting Procedures
Class 10: Abstracting ProceduresDavid Evans
 
Frsa
FrsaFrsa
Frsa_111
 
Functional Concepts for OOP Developers
Functional Concepts for OOP DevelopersFunctional Concepts for OOP Developers
Functional Concepts for OOP Developersbrweber2
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogrammingdudarev
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lispkyleburton
 
Monadologie
MonadologieMonadologie
Monadologieleague
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語ikdysfm
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programmingDamian T. Gordon
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpyFaraz Ahmed
 
C PROGRAMS - SARASWATHI RAMALINGAM
C PROGRAMS - SARASWATHI RAMALINGAMC PROGRAMS - SARASWATHI RAMALINGAM
C PROGRAMS - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3guesta3202
 
Class 16: Making Loops
Class 16: Making LoopsClass 16: Making Loops
Class 16: Making LoopsDavid Evans
 

Ähnlich wie Lisp and prolog in artificial intelligence (20)

Class 10: Abstracting Procedures
Class 10: Abstracting ProceduresClass 10: Abstracting Procedures
Class 10: Abstracting Procedures
 
Frsa
FrsaFrsa
Frsa
 
Procesos
ProcesosProcesos
Procesos
 
Functional Concepts for OOP Developers
Functional Concepts for OOP DevelopersFunctional Concepts for OOP Developers
Functional Concepts for OOP Developers
 
Scala @ TomTom
Scala @ TomTomScala @ TomTom
Scala @ TomTom
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lisp
 
Eta
EtaEta
Eta
 
Hadoop I/O Analysis
Hadoop I/O AnalysisHadoop I/O Analysis
Hadoop I/O Analysis
 
Clojure basics
Clojure basicsClojure basics
Clojure basics
 
Monadologie
MonadologieMonadologie
Monadologie
 
R Language Introduction
R Language IntroductionR Language Introduction
R Language Introduction
 
Vcs16
Vcs16Vcs16
Vcs16
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programming
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
 
C PROGRAMS - SARASWATHI RAMALINGAM
C PROGRAMS - SARASWATHI RAMALINGAMC PROGRAMS - SARASWATHI RAMALINGAM
C PROGRAMS - SARASWATHI RAMALINGAM
 
Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3
 
R meets Hadoop
R meets HadoopR meets Hadoop
R meets Hadoop
 
Class 16: Making Loops
Class 16: Making LoopsClass 16: Making Loops
Class 16: Making Loops
 

Kürzlich hochgeladen

Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceDelhi Call girls
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxolyaivanovalion
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...amitlee9823
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 

Kürzlich hochgeladen (20)

Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptx
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 

Lisp and prolog in artificial intelligence

  • 1. ARTIFICIAL INTELLIGENCE LISP and PROLOG Submitted to : Submitted by: Dr.arpana chaturvedi Arti kumari
  • 2. S No. CONTENT REMARK LISP 1 To print “hello world” in LISP 2 program To find the area of circle 3 to print odd number form 1-20 4 to print the average of number 10,20,30,40 5 defining macro OPERATORS 6 Arithmetic operator 7 Comparision operator 8 Logical operator DECISIONS CONSTRUCT 9 Cond 10 If 11 When 12 case LOOPS 13 Loop 14 Loop for 15 Do 16 dotimes 17 dolist 18 Predicate 29 Factorial of a number 20 Array 21 String 22 Sequence 23 list 24 Exiting from block 25 Let function 26 Prog function 27 Formatted output
  • 3. PROLOG 28 Print hello world using prolog. In console 29 prolog program to print hello world.. 30 Priya, Tiyasha, and Jaya are three girls, among them, Priya can cook 31 some rules. Rules contain some information that are conditionally true about the domain of interest. 32 Priya, Tiyasha, and Jaya are three girls, among them, Priya can cook. ;use of variable in our query 33 Prolog program, that can find the minimum of two numbers and the maximum of two numbers. 34 write a prolog program that will help us find the equivalent resistance 35 program to show working of Arithmetic operator in prolog 36 prolog program to print values from 1 to10 using loop 37 Example of decision making in Prolog. 38 prolog program to find the length of the list 39 prolog program to concatenate two list 40 Backtracking. 41 prolog program to find the cube of a number
  • 4. LISP Q1)To print “hello world” in LISP CODE: (write-line "Hello World") (write-line "I am at 'Online class' !- Learning LISP" )
  • 5. Q2) LISP program To find the area of circle .. CODE: (defconstantp13.141592) (defunarea-circle(rad) (terpri) (formatt " Radius:~5f"rad) (formatt "~%area:~10f" (* p1 rad rad))) (area-circle 10)
  • 6. Q3)LISP program to print odd number form 1-20 ? CODE: (loopfor x from 1 to 20 if(oddpx) do (printx) )
  • 7. Q4)LISP program to print the average of number 10,20,30,40 CODE: ;write a LISP program to find the average of numbers (defunaveragenum(n1 n2 n3 n4) ( / ( + n1 n2 n3 n4) 4) ) (write(averagenum10 20 30 40))
  • 8. Q5.defining macro CODE: (defmacro setTo10(num) (setq num 10)(print num)) (setq x 25) (print x) (setTo10 x)
  • 9. Q6)Arithmetic operators (setq a 10) (setq b 20) (format t "~% A + B = ~d" (+ a b)) (format t "~% A - B = ~d" (- a b)) (format t "~% A x B = ~d" (* a b)) (format t "~% B / A = ~d" (/ b a)) (format t "~% Increment A by 3 = ~d" (incf a 3)) (format t "~% Decrement A by 4 = ~d" (decf a 4))
  • 10. Q7) Comparison operator (setq a 10) (setq b 20) (format t "~% A = B is ~a" (= a b)) (format t "~% A /= B is ~a" (/= a b)) (format t "~% A > B is ~a" (> a b)) (format t "~% A < B is ~a" (< a b)) (format t "~% A >= B is ~a" (>= a b)) (format t "~% A <= B is ~a" (<= a b)) (format t "~% Max of A and B is ~d" (max a b)) (format t "~% Min of A and B is ~d" (min a b))
  • 11. Q8) logical operator (setq a 10) (setq b 20) (format t "~% A and B is ~a" (and a b)) (format t "~% A or B is ~a" (or a b)) (format t "~% not A is ~a" (not a)) (terpri) (setq a nil) (setq b 5) (format t "~% A and B is ~a" (and a b)) (format t "~% A or B is ~a" (or a b)) (format t "~% not A is ~a" (not a)) (terpri) (setq a nil) (setq b 0) (format t "~% A and B is ~a" (and a b)) (format t "~% A or B is ~a" (or a b)) (format t "~% not A is ~a" (not a)) (terpri) (setq a 10) (setq b 0) (setq c 30) (setq d 40) (format t "~% Result of and operation on 10, 0, 30, 40 is ~a" (and a b c d)) (format t "~% Result of and operation on 10, 0, 30, 40 is ~a" (or a b c d)) (terpri) (setq a 10) (setq b 20) (setq c nil) (setq d 40) (format t "~% Result of and operation on 10, 20, nil, 40 is ~a" (and a b c d)) (format t "~% Result of and operation on 10, 20, nil, 40 is ~a" (or a b c d))
  • 12.
  • 13. Q9) cond construct (setq a 10) (cond ((> a 20) (format t "~% a is greater than 20")) (t (format t "~% value of a is ~d " a))) Q10) If construct (setq a 10) (if (> a 20) (format t "~% a is less than 20")) (format t "~% value of a is ~d " a)
  • 14. Q11)When construct (setq a 100) (when (> a 20) (format t "~% a is greater than 20")) (format t "~% value of a is ~d " a)
  • 15. Q12)Case construct (setq day 4) (case day (1 (format t "~% Monday")) (2 (format t "~% Tuesday")) (3 (format t "~% Wednesday")) (4 (format t "~% Thursday")) (5 (format t "~% Friday")) (6 (format t "~% Saturday")) (7 (format t "~% Sunday")))
  • 16. Q13)Loop construct (setq a 10) (loop (setq a (+ a 1)) (write a) (terpri) (when (> a 17) (return a)) )
  • 17. Q14)Loop for (loop for x from 1 to 20 if(evenp x) do (print x) )
  • 18. Q15)Do construct (do ((x 0 (+ 2 x)) (y 20 ( - y 2))) ((= x y)(- x y)) (format t "~% x = ~d y = ~d" x y) )
  • 19. Q16)dotimes (dotimes (n 11) (print n) (prin1 (* n n)) )
  • 20. Q17)dolist (dolist (n '(1 2 3 4 5 6 7 8 9)) (format t "~% Number: ~d Square: ~d" n (* n n)) )
  • 21. Q18)predicate (write (atom 'abcd)) (terpri) (write (equal 'a 'b)) (terpri) (write (evenp 10)) (terpri) (write (evenp 7 )) (terpri) (write (oddp 7 )) (terpri) (write (zerop 0.0000000001)) (terpri) (write (eq 3 3.0 )) (terpri) (write (equal 3 3.0 )) (terpri) (write (null nil ))
  • 22. Q19)To find the factorial of a number (defun factorial (num) (cond ((zerop num) 1) (t ( * num (factorial (- num 1)))) ) ) (setq n 6) (format t "~% Factorial ~d is: ~d" n (factorial n))
  • 23. Q20)Array (write (setf my-array (make-array '(10)))) (terpri) (setf (aref my-array 0) 25) (setf (aref my-array 1) 23) (setf (aref my-array 2) 45) (setf (aref my-array 3) 10) (setf (aref my-array 4) 20) (setf (aref my-array 5) 17) (setf (aref my-array 6) 25) (setf (aref my-array 7) 19) (setf (aref my-array 8) 67) (setf (aref my-array 9) 30) (write my-array)
  • 24. Q21)String (write-line "Hello World") (write-line "Welcome to JAGANNATH INSTITUTE OF MANAGEMENT SCIENCES") ;escaping the double quote character (write-line "Welcome SIXTH SEMESTER")
  • 25. Q22) sequence (write (count 7 '(1 5 6 7 8 9 2 7 3 4 5))) (terpri) (write (remove 5 '(1 5 6 7 8 9 2 7 3 4 5))) (terpri) (write (delete 5 '(1 5 6 7 8 9 2 7 3 4 5))) (terpri) (write (substitute 10 7 '(1 5 6 7 8 9 2 7 3 4 5))) (terpri) (write (find 7 '(1 5 6 7 8 9 2 7 3 4 5))) (terpri) (write (position 5 '(1 5 6 7 8 9 2 7 3 4 5)))
  • 26. Q23)lists (write (cons 1 2)) (terpri) (write (cons 'a 'b)) (terpri) (write (cons 1 nil)) (terpri) (write (cons 1 (cons 2 nil))) (terpri) (write (cons 1 (cons 2 (cons 3 nil)))) (terpri) (write (cons 'a (cons 'b (cons 'c nil)))) (terpri) (write ( car (cons 'a (cons 'b (cons 'c nil))))) (terpri) (write ( cdr (cons 'a (cons 'b (cons 'c nil)))))
  • 28. Q25) let function (let((x 'a)(y'b) (z'c)) (formatt "x= ~a y= ~a z= ~a" x y z))
  • 30. Q27)Formatted output (setqx 10) (setqy20) (formatt"x=~2d y=~2d ~%" x y) (setqx 100) (setqy200) (formatt"x=~2d y=~2d" x y)
  • 31. PROLOG Q28) Print hello world using prolog.. CODE: write('Hello World'). Q29)prolog program to print hello world.. CODE: main :- write('This is sample Prolog program'), write(' This program is written into hello_world.pl file').
  • 32. Q30) Priya, Tiyasha,and Jaya are three girls, among them,Priya can cook. CODE: girl(priya). girl(tiyasha). girl(jaya). can_cook(priya). Q31) some rules. Rules contain some informationthat are conditionally true about the domain of interest. CODE: sing_a_song(ananya).
  • 33. listens_to_music(rohit). listens_to_music(ananya):- sing_a_song(ananya). happy(ananya):- sing_a_song(ananya). happy(rohit) :- listens_to_music(rohit). playes_guitar(rohit):- listens_to_music(rohit). Q32) Priya, Tiyasha,and Jaya are three girls, among them,Priya can cook. ;use of variable in our query CODE: can_cook(priya).
  • 34. can_cook(jaya). can_cook(tiyasha). likes(priya,jaya) :- can_cook(jaya). likes(priya,tiyasha) :- can_cook(tiyasha). Q33) Prolog program,that can find the minimum of two numbers and the maximum of two numbers. CODE: find_max(X,Y,X) :- X >= Y, !. find_max(X,Y,Y) :- X < Y. find_min(X,Y, X) :- X =< Y, !. find_min(X,Y, Y) :- X > Y.
  • 35. Q34) write a prolog program that will help us find the equivalent resistance.  If R1 and R2 are in Series, then equivalent resistor Re = R1 + R2.  If R1 and R2 are in Parallel, then equivalent resistor Re = (R1 * R2)/(R1 + R2).
  • 36.
  • 37. Q35)programto show working of Arithmetic operatorin prolog + Addition - Subtraction * Multiplication / Division ** Power // Integer Division mod Modulus
  • 38. Q36)prolog program to print values from 1 to10 using loop CODE: count_to_10(10):- write(10),nl. count_to_10(X) :- write(X),nl, Y is X + 1, count_to_10(Y). Q37) Example of decision making in Prolog. CODE: % If-Then-Else statement
  • 39. gt(X,Y) :- X >= Y,write('X is greateror equal'). gt(X,Y) :- X < Y,write('X is smaller'). % If-Elif-Else statement gte(X,Y) :- X > Y,write('X is greater'). gte(X,Y) :- X =:= Y,write('X and Y are same'). gte(X,Y) :- X < Y,write('X is smaller'). Q38)prolog program to find the length of the list ;? CODE: list_length([],0). list_length([_|TAIL],N) :- list_length(TAIL,N1),N is N1 + 1.
  • 40. Q39)prolog program to concatenatetwo list CODE: list_concat([],L,L). list_concat([X1|L1],L2,[X1|L3]) :- list_concat(L1,L2,L3).
  • 42. Q41)prolog program to find the cube of a number CODE: cube :- write('Write a number:'), read(Number), process(Number).
  • 43. process(stop) :- !. process(Number) :- C is Number* Number* Number, write('Cube of '),write(Number),write(': '),write(C),nl,cube.