The basic data types of the k9 language are booleans, numbers (integer and float), text (characters and enumerated/name) and temporal (date and time). It is common to have functions operate on multiple data types.
In additional to the basic data types, data can be put into lists (uniform and non-uniform), dictionaries (key-value pairs), and tables (transposed/flipped dictionaries). Dictionaries and tables will be covered in a seperate chapter.
The set of k9 data, aka nouns, are as follows.
Data types can be determined by using the
@ function on values or lists of values. In the case of non-uniform lists
@ returns the type of the list
`L but the function can be modified to evalue each type
@' instead and return the type of each element in the list.
@1 / integer atom `i @1 2 3 / integer list `I @12:34:56.789 / time atom @(3;3.1;"b";`a;12:01:02.123;2020.04.05) / mixed list `L @'(3;3.1;"b";`a;12:01:02.123;2020.04.05) `i`f`c`n`t`D
Booleans have two possible values 0 and 1 and have a ’b’ to avoid confusion with integers, eg. 0b or 1b.
0b 0b 1b 1b 10101010b 10101010b
Numbers can be stored as integers and floats.
3 3 3+1 4 @3 `i a:3; @a `i 3%1 / result will be float even though inputs are int 3f
3.1 3.1 3.1+1.2 4.3 3.1-1.1 2f @3.1-1.1 `f @3.1 `f a:3.1; @a `f
Text data come in characters, lists of characters (aka strings) and enumerated types. Enumerated types are displayed as text but stored internally as integers.
Characters are stored as their ANSI value and can be seen by conversion to integers. Character lists are equivalent to strings.
@"b" `c @"bd" `C
Names are enumerate type shown as a text string but stored internally as a integer value.
@`blue `n @`blue`red `N
Temporal data can be expressed in time, date, or a combined date and time.
Times are stored in hh:mm:ss.123 format and stored internally as integers.
@12:34:56.789 / time `t .z.t / current time in GMT 17:32:57.995 (t:.z.t)-17:30:00.000 00:03:59.986 t 17:33:59.986 `i 00:00:00.001 / numeric representation of 1ms 1 `i 00:00:01.000 / numeric representation of 1s 1000 `i 00:01:00.000 / numeric representation of 1m 60000 `t 12345 / convert milliseconds to time 00:00:12.345
Dates are in yyyy.mm.dd format and stored internally as integers.
@2020.04.20 / date `D .z.D / current date in GMT 2020.09.13 `i .z.D / numeric representation of date -1205 `i 2024.01.01 / zero date 0 `D 0 / zero date 2024.01.01
Dates and times can be combined as 2020.04.20T12:34:56.789.
@2020.04.20T12:34:56.789 / date and time `T "T"$"2020.04.20 12:34:56.789" / converting from string 2020.04.20T12:34:56.789 "T"$"2020.04.20 12:34:56.789" 2020.04.20T12:34:56.789 "T"$"2020.04.20T12:34:56.789" 2020.04.20T12:34:56.789 "T"$"2020.04.20T12:34:56.789" 2020.04.20T12:34:56.789
Data types can represent in-range, null, and out-of-range values.
|type||null||out of range|
0%0 0n 1e500 0w