5.2. Variable Pattern

When a variable pattern x is matched against a value v, the variable x is bound to the value v.

5.2.1. Syntax

[38]VariablePattern::= Variable  

5.2.2. Type

When a variable pattern x is matched against a type T, it produces the typing context { x has type T }.

5.2.3. Examples

Sum Pair
{- Sum the elements of a pair -}
val (x, y) = (3, 4)

x + y

{-
OUTPUT:
7
-}
Pair to List
{- Convert pairs to lists -}

( (3,4) | (2,6) | (1,5) ) >(x,y)> [x,y]

{-
OUTPUT:PERMUTABLE:
[1, 5]
[2, 6]
[3, 4]
-}

5.2.4. Related Links

Related Tutorial Sections