1. Squares of integers.
to output squares of two integers, we can use the goal 'outsquare'. Just enter the inputs you want, and it will be the range.
The example of the form :
This is the example of the program :
2. Define and testing predicate
this program using the repeat predicate. in this part, we use goal 'go'. This is the form :
after you consult the file, enter the goal 'go'. then, you need to enter the input you want. here is the output on SWI-PROLOG
3. Backtracking with failure
This followed program using 'backtracking with failure'. We will appearing the person with age above 40. Similiar with the former chapter on prolog, which use the 'find' function. Enter the facts that needed here, like first name, last name, age, city, and profession. Seems like this example :
Then, use the goal 'find'. Here's the output :
Tuesday, December 8, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment