Apply a function to every element of a tree. The map function handles an additional parameter called environment. You may either handle both subtrees simultaneously, or you can traverse the the tree in some given order
List of Import References :
See BOOL
See DENOTATION
See Nat
See Option
See Seq
See Tree
SIGNATURE TreeMapEnv[env,from,to]
$Date: 2010-09-30 18:24:17 +0200 (Do, 30. Sep 2010) $ ($Revision: 616 $)
IMPORT Tree[from] ONLY tree Tree[to] ONLY tree
env
is the data type of the additional parameter,
from
is the original data type of the elements of the tree,
to
is the new data type of the elements.
SORT env from to
Top-Down Direction First, from the current environment, and the root value, two new environments are computed for the left and right child respectively and a new value for the current node. The initial environment is used for computing the value of the root node.
FUN *_V : (env ** from -> env ** env ** to) ** env ** tree[from] -> tree[to]
Bottom-Up Direction First, the children are processed. The environments from the left and right subtree together with the current value are fed into the function which then returns a new environment and a new value. The initial environment is returned for the empty tree. The environment returned is the result from the root.
FUN *_^ : (env ** env ** from -> env ** to) ** env ** tree[from] -> env ** tree[to]
These functions visit the the nodes in preorder, inorder or postorder, always using the environment from the previous computation.
FUN *_pre *_in *_post: (env ** from -> env ** to) ** env ** tree[from] -> env ** tree[to]
next node: TreeReduce,
prev node: TreeMap,
up to node: Subsystem Binary Trees