CS 214: Programming Languages
Spring 2009

Home|Syllabus|Schedule
<<|>>|Prolog templates

Simple Facts and Rules
Prolog, Iteration 2

Work through Chapter 2 of Learn Prolog Now! (LNP!).

Unit Testing Hints

At least one example is taken from the documentation for PlUnit.

Exercise 2.1: Some of these assertions will seems silly (especially the early ones). For expressions with variables, add clauses to make the original expression true (if possible):

test(exercise2_1_8) :- food(X) = food(bread), X = bread.

Exercises 2.2 & 2.3: For expressions that bind a variable to multiple values, use the findall/3:

test(member) :-
  findall(X, member(X, [a,b,c]), Xs),
  Xs == [a,b,c].

The expression in bold is the one under test.