Type: Difference between revisions
Content added Content deleted
(changes in ngn/k types) |
No edit summary |
||
Line 35: | Line 35: | ||
| 16-bit (short) |
| 16-bit (short) |
||
|<code>5</code> |
|<code>5</code> |
||
|<code>"h"</code>|| |
|<code>"h"</code>|| <code>0 10000</code> |
||
|- |
|- |
||
| 32-bit (int) |
| 32-bit (int) |
||
|<code>6</code> |
|<code>6</code> |
||
|<code>"i"</code>|| |
|<code>"i"</code>|| <code>-2147483648 2147483647</code> |
||
|- |
|- |
||
| 64-bit (long) |
| 64-bit (long) |
||
|<code>7</code> |
|<code>7</code> |
||
|<code>"j"</code>|| |
|<code>"j"</code>|| <code>0N 9223372036854775807</code> |
||
|- |
|- |
||
| rowspan="2" |floats |
| rowspan="2" |floats |
||
Line 95: | Line 95: | ||
|- |
|- |
||
| 64-bit (long) |
| 64-bit (long) |
||
| colspan="2" |<code>-7</code> |
| colspan="2" |<code>-7</code>||<code>9223372036854775807</code> |
||
|- |
|- |
||
| rowspan="2" |float |
| rowspan="2" |float |
Latest revision as of 10:37, 23 October 2022
Type
@x
The type primitive returns a constant (usually a symbol or character or integer) identifying the type of a k value. The set of types varies a lot between dialects. Some implementations have types that are internally considered different (e.g. for the purposes of match) but presented to the user as identical.
In k2, k3, and kona[1] @x
returns 1 for atoms and 0 for non-atoms.
Type Classification | k4[2] | oK | ngn/k | k9 | Example | ||||
---|---|---|---|---|---|---|---|---|---|
list | generic
list |
mixed-type | 0
|
"*"
|
0 |
`A |
`* |
(0;`1;"2";{3};%)
| |
unitype | `LT
|
(0 1;2 3)
| |||||||
typed
list |
ints | 1-bit (bool) | 1
|
"b" |
N/A | `I |
0 1
| ||
8-bit (byte) | 4
|
"x" |
`I |
0 100
| |||||
16-bit (short) | 5
|
"h" |
0 10000
| ||||||
32-bit (int) | 6
|
"i" |
-2147483648 2147483647
| ||||||
64-bit (long) | 7
|
"j" |
0N 9223372036854775807
| ||||||
floats | 32-bit (single) | 8
|
"e" |
N/A | ? | ||||
64-bit (double) | 9
|
"f" |
`F |
`F |
3.14 -0w 0w 1.2e308 0n
| ||||
chars (string) | 10
|
"c"
|
`C
|
`C
|
"ab"
| ||||
symbols | 11
|
"s" |
`S |
`N |
``a`b
| ||||
temporals | 12..19
|
N/A | N/A | ? | |||||
table | 98
|
N/A | `M |
`A |
+`a`b!(0 1;2 3)
| ||||
dictionary | 99
|
99 |
`m |
`a |
`a`b!0 1
| ||||
atom | data
atom |
int | 1-bit (bool) | -1
|
-9 |
N/A | `i |
1
| |
8-bit (byte) | -4 |
`i |
100
| ||||||
16-bit (short) | -5 |
10000
| |||||||
32-bit (int) | -6 |
2147483647
| |||||||
64-bit (long) | -7 |
9223372036854775807
| |||||||
float | 32-bit (single) | -8 |
N/A | ? | |||||
64-bit (double) | -9 |
`f |
`f |
3.14
| |||||
char | -10
|
-10
|
`c
|
`c
|
"a"
| ||||
symbol | -11
|
-11 |
`s |
`n |
`
| ||||
temporal | -19..-12
|
N/A | N/A | ? | |||||
function | user-defined | 100
|
102 |
`o |
`. |
{}
| |||
primitive | monadic verb | 101
|
107
|
`u
|
+:
| ||||
dyadic verb | 102
|
`v
|
+
| ||||||
adverb | 103
|
N/A | `w
|
N/A | /
| ||||
projection | 104
|
107 |
`p
|
`. |
1+
| ||||
composition | 105 |
`q |
++
| ||||||
derived verb | 106..111
|
N/A | `r |
+/
| |||||
external | 112
|
N/A | `x |
? |