Skip to content
Some simple examples for new Prolog programmers
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
pirates fix not needed Jan 24, 2013
.gitignore
MonstersAndMazes.pl
README.md typo Mar 14, 2018
addlists.pl
adriandetective.pl
birds.pl
cannibals2.pl added cannibals.pl and updated README.md for it Oct 19, 2012
cannibals2nocomments.pl
charmichael.pl
children.pl Initial source checkin Oct 18, 2012
chrlearn.pl added a working num / inttype types example Dec 31, 2018
commonquestions.pl Added more examples Mar 25, 2017
complexcase.pl
constraintolist.pl
countrynames.csv Initial source checkin Oct 18, 2012
cuttutorial.pl
dcgexample.pl
ddedemo.pl send final versions of DDE related files to github Mar 25, 2017
detectivepuzzle.pl
emoticons.pl
example.xlsx send final versions of DDE related files to github Mar 25, 2017
exercises.md
expertsystem.pl Added more examples Mar 25, 2017
familytree.pl changed order of males to make it easier to step thru with students Feb 4, 2014
graph_data.pl exercises list and chrlearn.pl Dec 31, 2018
greenhouse.pl
latlong.pl
loops.pl Minor cleanup, added loops Jun 11, 2013
may15version.txt Initial source checkin Oct 18, 2012
newdetective.pl made a new version of detective. Apr 21, 2013
nqueens.pl added nqueens.pl Mar 14, 2018
numbergrammar.pl
prolog resources.txt Initial source checkin Oct 18, 2012
roguelike.pl Added more examples Mar 25, 2017
sendmoremoney.pl
socketdemo.pl
succmath.pl added succmath.pl and minor cleanup on detectivepuzzle.pl Apr 20, 2013
sudoku.pl
talespin2.pl
tictactoe.pl Initial source checkin Oct 18, 2012
worddoc.docx
wumpus.pl added wumpus.pl Feb 10, 2018

README.md

prolog-examples

Some simple examples for new Prolog programmers. Varying degrees of polish. Have fun.

finished examples

detective problem

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

talespin2.pl

Implementation of a classic story generator

tictactoe.pl

Implementation of tic tac toe

birds.pl

The birds example from the 'expert systems in Prolog' tutorial by Amzi (on the web)

cannibals2.pl

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

cuttutorial.pl

A little story analogy to help understand cut and cut, fail

emoticons.pl

A joke. I'm known for my happy array of 'smiley' emoticons. Sometimes others have trouble understanding my smileys. This program purports to help.

familytree.pl

The classic familytree example. This one has two separate families in it. (left as exercise for the reader to find the two disconnected groups).

socketdemo.pl

Demonstration of reading from a socket

Constraint examples

Examples of CLPFD

addlists.pl

Constrains two lists to pairwise add to a third.

children.pl

A fully worked problem involving seating children in a classroom

constraintolist.pl

A fully worked problem, constraining a variable to be a member of a list.

sudoku.pl

Solves a Sudoku puzzle by CLPFD

loops.pl

Demo of various ways to do in Prolog what you'd do with loops in an imperative language.

nqueens.pl

Implementation of the generalized version of the classic 8-queens problem.

You can’t perform that action at this time.