Logiweb(TM)

7.7.6 Tagged maps

Prev Up Next Page 202 of 800 Search internet


Consider the construct map ( x ) defined thus:

value define map ( x ) as MapTag LazyPair x end define

The construct takes a raw map x as input and returns a tagged map as output. the constant named MapTag is defined such that it happens to have the following value:

true LazyPair true LazyPair true LazyPair false LazyPair true

The exact value of MapTag is unimportant. And why that particular value was chosen is also unimportant. What counts is that Booleans, pairs, exceptions, integers, tagged maps, and objects have different tags and thus are distinguishable.

Note that mathematicians often talk about 'colors' instead of 'tags'. As an example, mathematicians may think of the direct sum of integers and rationals as a union of integers that are colored blue and rationals that are colored red.

It is stated above that map ( x ) takes a raw map x as input and returns a tagged map. Recall that 'raw map' is a synonym for 'map'. So we could just as well state that map ( x ) takes a map x as input and returns a tagged map.

Note that a tagged map is itself a map. Put otherwise, the set of tagged maps constitutes a subset of the set of all maps. There is a one-one relation between the set of maps and the set of tagged maps, and map ( x ) constitutes an isomorphism between the two sets.

Maps are suited for lazy evaluation and tagged data are suited for eager evaluation. The map ( x ) construct does not force evaluation of x and can be used for embedding lazy data inside eager data structures. Embedding the other way is trivial since the set of tagged data is a subset of the set of maps.

Prev Up Next Page 202 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05