Converting maps to/from sequences and to strings/denotations
List of Import References :
See BOOL
See Char
See DENOTATION
See Map
See Nat
See Option
See Pair
See Seq
See Set
See String
SIGNATURE MapConv[dom, <, codom]
$Date: 2010-09-30 18:24:17 +0200 (Do, 30. Sep 2010) $ ($Revision: 616 $)
IMPORT Map[dom, <, codom] ONLY map Seq[pair[dom, codom]] ONLY seq Pair[dom, codom] ONLY pair String ONLY string
dom
and codom
are the types of the map domain and
codomain resp. <
is a total strict
order: the formula ALL x y. ~(x < y) AND ~(y < x) => x === y must
hold.
SORT dom codom FUN < : dom ** dom -> bool
Transform map m
into a sequence of pairs, each pair
consisting of domain element and its associated codomain
element. Informally, asSeq({d1 -> c1, ..., dn -> cn
) = <&(d1,
c1), ..., &(dn, cn)>}
FUN asSeq: map -> seq[pair]
Transform a sequence of pairs into a map; each pair has to consist
of a domain and a codomain element. Informally,
asMap(<&(d1, c1), ...,&(dn, cn)>) = {d1 -> c1, ..., dn ->
cn
}. If di = dj
with i |= j
, then
asMap(..)!di
may be either ci
or cj
.
FUN asMap: seq[pair] -> map
`(d,c)({d1 -> c1, d2 -> c2, ..., dn -> cn})
==
"{" d(d1) " -> " c(c1) "," d(d2) " -> " c(c2) "," ... ","
d(dn) " -> " c(cn) "}"
FUN ` : (dom -> denotation) ** (codom -> denotation) -> map -> denotation FUN ` : (dom -> string) ** (codom -> string) -> map -> string
Here, you can replace "->"
, "{"
, ","
"}"
by your favourite denotations:
`(d,c)(m) == `("->")("{",",","}")(d,c)(m)
FUN ` : denotation -> denotation ** denotation ** denotation -> (dom -> denotation) ** (codom -> denotation) -> map -> denotation FUN ` : denotation -> denotation ** denotation ** denotation -> (dom -> string) ** (codom -> string) -> map -> string
Do not use functions from this section!
FUN explode: map -> seq[pair] -- explode == asSeq FUN implode: seq[pair] -> map -- implode == asMap
next node: MapFilter,
prev node: MapNotForUserPurpose,
up to node: Subsystem Maps Proper