Wafl Home

Tuple Tutorial

Tuple

Tuple is fixed size structured data type. While single tuple may consist of elements of different types, the type of each element is fixed.

Tuple data type is written as Tuple[<el1-type>, <el2-type>, ..., <eln-type>].

Tuple literals begin by {# and end by #}, with elements separated by commas. Tuple may not be empty.

Braces are used not only for literal tuple specification, but also as a tuple construction operator.

Several tuples are presented in the following example, with their types described in comments. In many of presented examples tuples are used to define the evaluation of multiple values.

Source code:

// Tuple[
//   Tuple[Integer],
//   Tuple[Integer, String],
//   Tuple[Integer,Tuple[String,List[Integer]]]
//   ]
{#
// Tuple[Integer]
{# 1 #}, 
// Tuple[Integer, String]
{# 1 + 2,'a'+'b' #}, 
// Tuple[Integer, Tuple[String, List[Integer]]]
{# 1,{# 'list',[1,2,3] #}#}
#}

Result:

{# {# 1 #}, {# 3, "ab" #}, {# 1, {# "list", [1,2,3] #} #} #}

 

Table of Contents

Let's Start

Program Structure

Primitive Data Types

List

Tuple

Record

HTML

Command Line Interpreter

Using Web Servers

Syntax

Examples

Tips

The most of examples evaluates with both command line and Web server Wafl interpreters. If any example is based on specific features of an interpreter, it is explicitly annotated.