hei . nice to see you again .
ok now we will do exercise 6 from book Logic Programing with Prolog .
Practical Exercise 6
(1) Define a predicate to output the values of the squares of the integers from N1 to N2 inclusive and test it with N1 = 6 and N2 = 12.
for answer number 1 its very easy . you should do it step by step .
ok, lets se the step .
1. first you must write a rules in notepad .
2. second you save it .pl
3. and then open the Prolog and and consult the file.
4. then you should write the instruction outsquare(7,10) . for this, you can write everything number that you like .
5.push enter .
6. so the result is :
(2) Define and test a predicate to read in a series of characters input by the user and output all of those before the first new line or ? character.
for number 2 , we should be careful .
lets do it together .
1. for step one , we must write a rules in notepad an then save .pl .
2. step two, open the prolog and consult the file .
3. then write instruction go. , push enter .
4. and then we can write everything you like, push enter again .
5. so, the result is :
6. but if you insert a character like '?' . it is only repeat word before character , but if you write again, it can't be repeat . it only once .
if you confuse , this is the example .
(3) Using the person clauses given in Section 6.3.1, find the professions of all those over 40.
this is the step to answer number 3.
1. first you must write a rule in notepad .
2. save it .pl
3. open the prolog and consult this file .
4. then write an instruction find. , and the result are is :finish . ^.^
FP REPORT
15 tahun yang lalu
Tidak ada komentar:
Posting Komentar