![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_MHjbBM5XhiSwCiRStkx6fLxkV1Zh0dhckexnfOOniOjshQwfXUqONWPw6KXT12us72YO-9icNThrigxb6siY3mNJUTbp9l-ZMxLGPzhZrW5oA7J3eMlrNK3KrKBWD1YuODws1JIN3V8/s200/prologa.jpg)
On this first post, we will give a tutorial using the Prolog (Programming Logic) Language. The title of this post is "How to Make All Possible Combination of 2 Sets with Prolog". From the title we can get general description of this first tutorial. Okay, let's start!
But, before that, we need some preparation,
1. First, you need a computer that has text-editor program like notepad, wordpad, ms word etc.
2. Then, you also need prolog language compiler (in this tutorial we use swi-prolog).
3. And the last one, you need some spirit. So that we can finish this. Hehehehehe. Let's Begin!
To Make All Possible Combination of 2 Sets with Prolog, that must be done is:
First, type the elements of 2 sets in notepad like this!
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMRMud-YwrcaaeqE0x6uj_XKFuJUkOGiSk9_5JMbgUsAZA_CzllxttTRoSFwWLn5PNClX5YqBh_0QqVXfUXcI-G8fdTBnfxLjmvz2_yz-WtJ248RImwX9lFd02KBIh9ebFvsik1b-_tlU/s320/1.png)
Student and course is the name of 2 sets. Musa, Kukuh, Nanda is the elements of student set. Discrete and alpro is the elements of the course set. Then, save the file with prolog extension (*.pl) to the harddrive.
Second, open swi-prolog (you must install this software first to your computer). Then click file, and select consult menu.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim7pToLZ9WKEJwHtz_5ifgrEBq7sk2US-5qfslOjlQh4PvzWMF1s8BCwxHhvzL30-CvXhlI0eH5rZuq4HupzlJSYDKjY7_J17Cp9t8ggGNQih3HpCBvx1cFhH5twLpwOyBjHQlQp3mr40/s320/3.bmp)
Find the last prolog file (*.pl extension) that edited in notepad then press ok.
Third, type "student(X), course(Y)." without quotes. But, before that you must know that now we are in prolog compiler (swi-prolog) work layer. Okay, back to the topic, if you typed, press enter. After that you'll see like this,
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8HE4a8k0pPzF3fOcKto6IGnasFrKxjhWCJkrikFd-8mARvOwvPbQ0y39K0mJ3jRVN0c5GnSgADx_xGbE7prRxffYGRav0GCwx_Rj6I_xmMKXRQdRpbD8GjfBrgUwDm4jFkNCzwywzZaI/s320/2.png)
The image show all combination of 2 sets (student and course). You also can type "course(X), student(Y)." to see other combination like this,
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy861TCcLoHIg0mb0MR6ibwte3Kg7jEdkLvUJ3oi3xEmOVklbbef2ll8zIyrUnU2Pr_BhRkGSdAWd2p4aKp11D6YiSfntmJQaFgAfL987E4Khd52R7WAuI-tpBwltvHLtO0ZxLLLckPSM/s320/3.png)
How about we type "student(X), course(Y)."? It means gives all elements which are both a student and a course (there are no such elements in the database). So, the result of the program is "No". You can see here,
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj17jDiqsw4lQZxGEOtmHE8JaFeExtVMv4TvizqWWfSV3rNU7k9WJDDQCR07ughkLekDOtFKmisvujrzZF8x37kDTO0XQTk3_ePs6f08AK5U3LSpDe4Bh6cFEBazsVa8Zkmg62lh17lFA/s320/4.png)
Okay, maybe just it tutorial for this time. We'll continued to another time with the next tutorial and still with prolog. Hopefully this first post is helpfully.
https://discreteaddict.blogspot.com/2009/10/how-to-make-all-possible-combinations.html