Site under construction! :3
toki pi ilo sonaξ―
toki pi ilo sona is a stack-based, minimalist, base 6 programming language for speakers of toki pona!
Typesξ―
kulupu
: group (array, dictionary, object, set, etc.)nimi
: stringnanpa
: numberpali
: functionlon
/ala
: true / false
Keywordsξ―
la
/ante
: if / elsetawa
: for / while looppini
: end / breakpakala
: errorsin
: newkama
: returnli
: iso
: do, calculateopen
: firsttan x insa y
: fromx
importy
Operatorsξ―
Boolean operatorsξ―
kin
(!): andanu
(Y): orala
(X): not
Numerical operatorsξ―
en
(+): addweka
(-): subtract, deletemute
(*): multiplykipisi
(%): divide
Comparison operatorsξ―
sama
(=): equalssuli
(V): (size, used with+
and-
;x -V y
=x is less than y
)seme
(?): (question, used with=
;x ?= y
does x == y
)
Built-in functionsξ―
toki
: print
Example programsξ―
Hello world!ξ―
> toki "Hello world!"
"Hello world!"
Sum a listξ―
With symbolsξ―
> pali Sum(kulupu: kulupu):
> nanpa Total = 0
> tawa kulupu li lon:
> Total = Total + kulupu open
> weka kulupu open
> kama Total
> kulupu A = [1, 2, 3, 4, 5]
> toki Sum(A)
15
Without symbolsξ―
> pali Sum(kulupu li kulupu)
> nanpa Total sama ale
> tawa kulupu li lon
> o Total sama Total en kulupu open
> weka kulupu open
> pini
> kama Total
> kulupu A sama [wan, tu, tu wan, tu tu, luka]
> toki Sum(A)
15