lab4 - Prolog programming

Topics:

Today, we will focus on list and get a better feeling about how Prolog works.

Here are the fixed samples we run last time.

1. Some list program examples.

2. Usage of Accumulators

3. How prolog searches.

Try following database with the query, why prolog answers in this sequence?

Assignments:

simple list operation: print 2nd,4th...elements in the list. (need to finish today).

find a path in a graph, build your own database(finish today)

flight problem.(This assignment due extended)

challenge problem: The Towers of Hanoi.

The Towers of Hanoi is a game played with three poles and a set of discs. The discs are graded in diameter, and fit onto the poles by means of a hole cut through the center of each disc. Initially all the discs are on the left-hand pole. The object of the game is to move all of the discs onto the center pole. The right-hand pole can be used as a "spare" pole, a temporary resting place for discs.