Next: , Previous: , Up: Top  


6 Noun

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.

Atom   Example     
bool,  011b           
int,   0N 2 3       
flt,   0n 2 3.4     
char,  " ab"          
name,  ``ab
uuid,  
time,  12:34:56.123456789   
date, 2024.01.01T12:34:56 

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

6.1 bool ⇒ Boolean b

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

6.2 Numeric Data

Numbers can be stored as integers and floats.

6.2.1 int ⇒ Integer i

Integers

 3
3
 3+1
4
 @3
`i
 a:3;
 @a
`i
 3%1   / result will be float even though inputs are int
3f

6.2.2 flt ⇒ Float f

Float

 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

6.3 Text Data

Text data come in characters, lists of characters (aka strings) and enumerated types. Enumerated types are displayed as text but stored internally as integers.

6.3.1 char ⇒ Character c

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 

6.3.2 name ⇒ Name n

Names are enumerate type shown as a text string but stored internally as a integer value.

 @`blue
`n
 @`blue`red
`N

6.4 Unique Identifier

TBD

6.4.1 uuid ⇒ Uuid

TBD

6.5 Temporal Data

Temporal data can be expressed in time, date, or a combined date and time.

6.5.1 time ⇒ Time t

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

6.5.2 date ⇒ Date D

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

6.5.3 datetime ⇒ Datetime S

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

6.6 Extreme values

Data types can represent in-range, null, and out-of-range values.

typenullout of range
i0N0W
f0n0w
 0%0
0n
 1e500
0w

Next: , Previous: , Up: Top