Previous Page

NonDeterministic Computations Rules Specifications Modularity and parameterization 
Next Page

The list composed of elements a and b is thus represented
by the term a.b.nil. Given a function
f(@): (Element) Element,
we define mapf(@): (List) Element by the following rewrite rules
where
element and list are respectively local variables
of sort Element and List.
[head] mapf(element.list) => f(element) end
[tail] mapf(element.list) => mapf(list) end
Then we introduce a constant strategy operator mapStrat defined
by the following strategy rule
[] mapStrat => iterate*(dc one(tail));dc one(head) end
mapStrat applied on mapf(a.b.c.nil) returns successively f(a), then f(b) and finally f(c). If f is defined as the identity on Element, we get a strategy called listExtract that extracts all elements of a list. This illustrates how the notion of strategy can be used to compute a set of normal forms without using explicitly a notion of set.