Skip to main content

Map

rascal-0.34.0

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:

Examples

rascal>("pear" : 1, "apple" : 3, "banana" : 0);
map[str, int]: ("banana":0,"pear":1,"apple":3)