Map
rascal-0.40.17
Synopsis
Map values.
Syntax
( KeyExp₁ : ValExp₁, KeyExp₂ : ValExp₂, ... )
Types
KeyExp₁ | ValExp₁ | KeyExp₂ | ValExp₂ | ... | ( KeyExp₁ : ValExp₁, KeyExp₂ : ValExp₂, ... ) |
---|---|---|---|---|---|
TK₁ | TV₁ | TK₂ | TV₂ | ... | map[lub(TK₁, TK₂, ... ) , lub(TV₁, TV₂, ... )] |
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
- Comprehension
- Difference
- Equal
- Intersection
- NotEqual
- StrictSubMap
- StrictSuperMap
- SubMap
- Subscription
- SuperMap
- Union
- In
- Notin
Examples
rascal>("pear" : 1, "apple" : 3, "banana" : 0);
map[str, int]: ("banana":0,"pear":1,"apple":3)