forked from sejo/compudanzas
k page
This commit is contained in:
parent
742ace936d
commit
bc9752d845
|
@ -11,3 +11,7 @@ a programming language
|
|||
|
||||
=> https://mlochbaum.github.io/BQN/index.html BQN: finally, an APL for your flying saucer
|
||||
=> https://mlochbaum.github.io/BQN/tutorial/index.html BQN tutorials
|
||||
|
||||
# K
|
||||
|
||||
=> ./k.gmi {k}
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
# k programming language
|
||||
|
||||
a flavor of {apl}, i understand?
|
||||
|
||||
# resources
|
||||
|
||||
=> https://codeberg.org/ngn/k ngn/k
|
||||
=> https://ngn.codeberg.page/k/# ngn/k online
|
||||
|
||||
# notes from eris' k class
|
||||
|
||||
operator precedence: always from right to left.
|
||||
|
||||
types:
|
||||
|
||||
* integer (list of)
|
||||
* float (list of)
|
||||
* character (list of/string)
|
||||
* dictionary (list of/table)
|
||||
* symbol (list of)
|
||||
|
||||
lists are enclosed between parenthesis, and items separated with semicolons
|
||||
|
||||
```
|
||||
(1;2;3)
|
||||
("a";"b";"c")
|
||||
```
|
||||
|
||||
equivalent to:
|
||||
|
||||
```
|
||||
1 2 3
|
||||
"abc"
|
||||
```
|
||||
|
||||
|
||||
assignment is done with :
|
||||
|
||||
```
|
||||
a: 1
|
||||
b: 1 2 3
|
||||
```
|
||||
|
||||
## verbs
|
||||
|
||||
minus sign (-), unary is negate, binary is subtraction:
|
||||
|
||||
```
|
||||
- 1 2 3
|
||||
result -1 -2 -3
|
||||
|
||||
2 - 1
|
||||
result 1
|
||||
```
|
||||
|
||||
plus sign (+), binary is addition:
|
||||
|
||||
```
|
||||
1 + 2
|
||||
result 3
|
||||
```
|
||||
|
||||
asterisk (*), unary is "first", binary is multiplication
|
||||
|
||||
```
|
||||
2 * 3
|
||||
result 6
|
||||
|
||||
* 3 2 1
|
||||
result 3
|
||||
```
|
||||
|
||||
vertical bar (|), unary is reverse, binary is mod?
|
||||
|
||||
```
|
||||
|1 2 3
|
||||
result 3 2 1
|
||||
```
|
||||
|
||||
with colon (:) one can force the use of the unary mode, e.g.
|
||||
|
||||
```
|
||||
*: 3 2 1
|
||||
```
|
||||
|
||||
exclamation mark (!) applied to an integer produces the natural numbers from 0 to that integer minus one:
|
||||
|
||||
```
|
||||
!5
|
||||
result 0 1 2 3 4
|
||||
```
|
||||
|
||||
percent sign (%) is division
|
Loading…
Reference in New Issue