Skip to content

Examples

In this section, we have provided some simple examples using the. They are meant to give you an idea of how scripts are constructed.

For a full language reference, please refer to Language Reference section.

Returning values

// Return a text:
from 'This returns a text'
// Return a number:
from 1.5

Define and call a function

let myFunc (param) => param + param
from myFunc(2)

Define and call a filter

let add (a, b) |> a + b
from (1, 2) add

Define and call an operator

let add (a) |> (b) => a + b
from 1 add 2

Arithmetic

from 1 + 2 * 3 / 4

Conditional operator

let if val |> (predicate) when predicate => val
let else predicate |> val when predicate is nothing => val
from 1 if true else 2

Pattern matching

param i: text | number = 2
from i match
text |> 'i is a text'
number |> $'i doubled is {i*2}'

Mapping a List

let arr = [1,2,3,4]
from arr select v => v + 1