TYPICAL / Guided Tour / Type
Bottom 

Case-study: Complex list structures

Flattening an embedded list

With the simple typing list(top) a type error is overseen.

File flatten
Output of type checking (flatten.tap)

No improvement in typing, but the malformed list [1|2] causes a Prolog failure:

File flatten_improved
Output of type checking (flatten_improved.tap)

Problem: typing an embedded list
The following examples offer some solutions.

Typing an embedded list

Possibilities for typing a list of atomics and lists

use of list(top)

File list_top
Output of type checking (list_top.tap)

use of special type element(T)

File list_element
Output of type checking (list_element.tap)

Typing a commalist

A commalist is a structure like "(1, 3, 2, 4)"

Problem: Contrary to a normal list structure, a commalist has no end-element like "[]"

use of special type element(T)

File commalist
Output of type checking (commalist.tap)

Typing a predicate, which takes an atomic or a list as argument

use of special type element(T)

File pred
Output of type checking (pred.tap)

Top 
PREV: Predicate declaration examples
NEXT: Syntax of meta-type

TYPICAL / Guided Tour / Type