Navigation
|
Synopsis Map values.
Syntax ( KeyExp1 : ValExp1, KeyExp2 : ValExp2, ... )
Types KeyExp1 | ValExp1 | KeyExp2 | ValExp2 | ... | ( KeyExp1 : ValExp1, KeyExp2 : ValExp2, ... ) |
---|
TK1 | TV1 | TK2 | TV2 | ... | map[lub(TK1, TK2, ... ) , lub(TV1, TV2, ... )] |
Usage import Map ; (included in Prelude)
Description A map is a set of key : value pairs and has the following properties:
- Key and value may have different static types.
- A key can only occur once.
Maps resemble functions rather than relations in the sense that only a single value can be associated with each key.
The following functions are provided for maps:
- Composition: Composition of two map values.
- Comprehension: A map comprehension generates a map value.
- Difference: The difference between two maps.
- Equal: Equality operator on maps.
- in: Membership test on the keys of a map.
- Intersection: Intersection of two maps.
- NotEqual: Not equal operator on map values.
- notin: Negated membership test on the keys of a map.
- StrictSubMap: Strict submap operator on map values.
- StrictSuperMap: Strict supermap operator on map values.
- SubMap: Submap operator on map values.
- Subscription: Retrieve a value by its key in map.
- SuperMap: Supermap operator on map values.
- Union: Union of two maps.
Examples rascal>("pear" : 1, "apple" : 3, "banana" : 0);
map[str, int]: ("banana":0,"pear":1,"apple":3)
|