Map Expression

From VisItusers.org

Jump to: navigation, search

[edit] 'map' expression

This expression is similar to the 'enumerate' expression, but preforms a mapping operation instead of an index lookup & assigns a default for input values that do not exist in the map.

[edit] Syntax

map(var,[TO list])
map(var,[TO list],default value)
map(var,[FROM list],[TO list])
map(var,[FROM list],[TO list], default value)

[edit] Examples

map(var,[0,1,2,3],[10.0, 15.0,30.0,45.0])

Implements the mapping function:

  • 0 -> 10.0
  • 1 -> 15.0
  • 2 -> 30.0
  • 3 -> 45.0
  • Any other value -> -1
map(var,[0,10,20,30],["zero tens","one ten","two tens","three tens"])

Implements the mapping function:

  • 0 -> "zero tens"
  • 10 -> "one ten"
  • 20 -> "two tens"
  • 30 -> "three tens"
  • Any other value -> "<undefined>"
map(var,["here","there","everywhere"])

Implements the mapping function:

  • 0 -> "here"
  • 1 -> "there"
  • 2 -> "everywhere"
  • Any other value -> "<undefined>"
Personal tools