Some simple examples for new Prolog programmers. Varying degrees of polish. Have fun.
These are two approaches to solving a detective's problem. She's interrogated three witnesses to a murder, all of whom are also suspects. The problem is to determine which of the suspect's testimony is inconsistent with the others.
- detectivepuzzle.pl - My original solution, written when I was new to Prolog. It now feels very 'imperative'
- newdetective.pl - I recently rewrote it
- adriandetective.pl - Adrian King's solution
Implementation of a classic story generator (note that a far better implementation is at https://github.com/SWI-Prolog-Education/talespin-annie)
Implementation of tic tac toe
The birds example from the 'expert systems in Prolog' tutorial by Amzi (on the web)
A well commented example of the cannibals/missionaries problem
This was used as an example for a talk whose notes are in may15version.txt
cannibals2nocomments.pl has fewer comments, but has some additional capabilities
A little story analogy to help understand cut and cut, fail
A joke. I'm known for my happy array of 'smiley' emoticons. Sometimes others have trouble understanding my smileys. This program purports to help.
The classic familytree example. This one has two separate families in it. (left as exercise for the reader to find the two disconnected groups).
Demonstration of reading from a socket
Examples of CLPFD
Constrains two lists to pairwise add to a third.
A fully worked problem involving seating children in a classroom
A fully worked problem, constraining a variable to be a member of a list.
Solves a Sudoku puzzle by CLPFD
Demo of various ways to do in Prolog what you'd do with loops in an imperative language.
Implementation of the generalized version of the classic 8-queens problem.
solve game 'tech tree' problems using CHR.