| OCR Text |
Show Example 9. Data type Queue is_empty(newq) = true is_empty(add(Item, Queue)) = false remove(add(Item, Queue)) = if is_empty(Queue) then newq else add(Item, remove(Queue)) front(add(Item, Queue)) = if is_empty(Queue) then Item else front(Queue) The function if- then- else can be defined as : if_then_else(true, X, Y) = X if_then_else(false, X, Y) = Y 0 Example 10. A Curried version of the function map map(F)([]) = [] map(F)(AAL) = F(A)Amap(F)(L) The syntax of this example resembles the Curried version of function definitions. This example illustrates that the result of a computation can be a function; we will call such functions resulting func-tions. As a consequence, the function variable F can be instantiated by a resulting function. A function call like map (map(plus1)) ([[1,2], [3,4]]) is valid, and can be reduced to [ [ 2, 3], [ 4, 5]] where the function plus1 is defined as plus1(N) = N+1, and map(plus1) is a resulting function. 0 6.1.1 Reduction of Function Terms 104 A set of equations can be viewed as a term rewriting system, where each equation serves as a rewrite rule, if such a term rewriting system has the con-fluence property. Intuitively, the confluence property says that if a term A can be reduced to either of two terms B or C by two distinct reduction sequences, then there must exist a term D such that both B and C can be reduced to D. The problem of determining whether a term rewriting system has the con-fluence property is unsolvable in the general case. Sufficient conditions have, |