Welcome to Lucian's Pedagogy.

This site contains information to help you understand the marking process in humanities, creative arts and science essays.

Please read the Table of Contents (Welcome!) . To earn A, (in an assignment, to have a healthy baby or use 50 As to earn a job) please visit the Anarchy Quiz.

Friday, May 7, 2010

Input and Output

For each of the reasons from the essay, detailed reasoning and mind map, write programs which describe a transformation of data from input to output in Prolog.

For example, the Prolog predicate roompart1/5 calculates the closest part of the room (i.e. an object in the room) to a person. It takes the following arguments:

roompart1(+RoomParts, +LowerBound, +UpperBound, +Position1, -RoomPart1)

(+ means input and - means output)

RoomParts - list of room parts in the format [Position, Name]
LowerBound - Lowest position number
UpperBound - Highest position number
Position1 - The person's position
RoomPart1 - The closest room part to the person to return

A sample query for the program would read as follows:

roompart1([[0, space], [1, space], [2, table], [3, seat], [4, space]], 0, 4, 3, RoomPart).

The result would be:

RoomPart = seat

No comments:

Post a Comment