The most wellknown on mathemathics lesson is sets. What is sets? Sets is a collection of well-defined object.
To definite subset operation, we will begin with definite a new predicate sis/2.
- Firstly,write op(710,xfx,sis). On SWI-prolog then press enter .
- Second, Write op(200,yfx,and). Then press enter
- Write again op(200,yfx,or). Then press enter
We don’t need to definite the minus operator for difference because its already been definited.
Now we need the definition from and, or, and – when we using sis connector. We use findall/3 predicate. Write on the notepad then save with format .pl
Example : lap.pl
This is used to find all of element’s member that same from A and B sets, all of member on A or B sets, and all of member in A but not exist in B.
Then, on the prolog, we consult the data that has been saved. File – Consult – lap.pl. then press enter.
Now,we write the member of sets on prolog, then follow the instruction A sis F and M, so do for or and –
Example : F=[acer,toshiba,dell.apple],M=[dell,apple,fujitsu]. Then press enter. so do for Or and –
Now, we are trying to combine chance from two sets. Here, example of chance from two sets about laptop and operation system.
- Write the member of sets on notepad, then save with .pl format
- Open swi-prolog program, choose File - consult – choose our data .pl
- On prolog, write laptop(X),operationsystem(Y). And don’t forget to give .(dot/titik) on the last sentence.Then press enter.
- Then will appear the first chance. Then press ( ; ) until the last chance appear and NO also appeared.
That’s all the way to combine two sets on prolog. Actually this is very easy if we want to try it and do more practice. FIGHTING!!!
^_^
For make it clearly, please click this file!
No comments:
Post a Comment