is_map

From the SETL Wiki

Jump to: navigation, search
is_map
Category predicate
Syntax prefix
Compatibility
CIMS SETL yes
SETL-S yes
SETL2 yes
GNU SETL yes

Contents

Purpose

Determine whether the specified value is a map

Synopsis

 is_map x

Description

Returns true if:

  1. x is a set and
  2. every element of x is a pair, i.e. a tuple of length 2 whose first element is not om.

SETL2 also allows a tuple of length 1 in a map, representing a key that is mapped to om.

Examples

  1. is_map {['a', 1], ['b', 2]}
    

    Result: true

  2. is_map {}
    

    Result: true

  3. is_map {42}
    

    Result: false

  4. is_map {['a', 1], 42}
    

    Result: false

  5. is_map {['a', 1], [om, 2]}
    

    Result: false

  6. is_map({['a', 1], ['b']})
    

    Result: true in SETL2, false in all other implementations. Note that SETL2 requires the parentheses around the operand.