-
Notifications
You must be signed in to change notification settings - Fork 0
Predefined types
The type bool
can either be no
or yes
:
yes or no = yes
yes xor yes = no
yes and no = no
-
yes != no
is true
The type int
can contain any integer without any limit:
-
-123
is an integer -
100e50
is also an integer -
10 < 20
is true
The type float
can contain a floating point numbers with 64 bit precision. They always are expressed with a point.
-
-12.45
is a float -
34.0e10
is a float -
-10.0 > -20.0
is true
The type str
contains a sequence of Unicode characters. While strings are not strictly scalar, they can be compared. The braces, unless doubled, introduce the formatting of a value.
-
"hello" < "world"
is true -
"I have {appleCount} apples" = "I have 3 apples"
whenappleCount = 3
-
"Press {{Enter}} please"
will be in factPress {Enter} please
The void value ()
is the only possible value for the void type ()
. It can be used as parameter or return value to indicate that no value is expected.
-
() greetings
calls the functiongreetings
without parameter (a function call is always in second position) -
var f int -> ()
indicates the type for a function f taking an int as parameter and returning nothing
Types can be combined into composite types: tuple, list, enumerator, linked list, set, dictionary, record and tagged value.
Most composite types support concatenation operator ++
except the tagged value.
A optional type is the union of the #ok
and of the #none
type. It can be expressed by putting ?
suffix:
-
int?
is the same as the type#ok int | #none
and indicates either a number or void -
str?
is either#none
, the empty string#ok ""
or a non empty string -
name ?? "noname"
will coalesce to the value"noname"
ifname
is#none
and otherwise will equal the value after#ok
. For example#ok 12 ?? 0
will give12
and#none ?? 0
will give0
.