lec2 Prolog language Lec3 By MSC.Noor Hassan More

lec2 Prolog language Lec3 By MSC.Noor Hassan More
1 / 1
lec2 Prolog language Lec3 By MSC.Noor Hassan More - slide 1 of 8 lec2 Prolog language Lec3 By MSC.Noor Hassan More - slide 2 of 8 lec2 Prolog language Lec3 By MSC.Noor Hassan More - slide 3 of 8 lec2 Prolog language Lec3 By MSC.Noor Hassan More - slide 4 of 8 lec2 Prolog language Lec3 By MSC.Noor Hassan More - slide 5 of 8 lec2 Prolog language Lec3 By MSC.Noor Hassan More - slide 6 of 8 lec2 Prolog language Lec3 By MSC.Noor Hassan More - slide 7 of 8 lec2 Prolog language Lec3 By MSC.Noor Hassan More - slide 8 of 8
lec2 Prolog language Lec3 By MSC.Noor Hassan More examples This lecture present several example that intended to display various way to write prolog program, how to write if else program ,divide problem into several parts then combine them

Related Topics

Download this presentation From Below

"lec2 Prolog language Lec3 By MSC.Noor Hassan More" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentation Transcript

01
lec2 Prolog language Lec3 By
MSC.Noor Hassan<br>
02
More examples
This lecture present several example that intended to display various
way to write prolog program, how to write if –else program ,divide
problem into several parts then combine them in a single rule and how to
write program describe specific problem.<br>
03
Example 1: write prolog program to check if the given number is positive
or negative.
Basic rule to check the number
If X>=0 then
X is positive
Else
X is negative
Domains
I= integer
Predicates
Pos_neg(i)
Clauses
Pos_neg(X):-X>=0, write(“positive number”),nl.
Pos_neg(_ ):-write(“negative number”),nl.
Goal
Pos_neg(4)
Output:
Positive number
Note: nl mean new line.<br>