→ README, → prev: Primitives, Builtins & Prelude, → next: Possible Future Extensions
→ IO, → JSON, → Math, → Str, ...
NB: work in progress.
NB: the io
module is built-in (and does not need to be require
d or
use
d; it can of course still be import
ed).
>>> "lib/_test.knk" io.contents! 24 [-j) ; file contents
"\"loading module _test..."
>>> , "lib/_test.knk" io.lines! ; file lines
>>> , "loading" grep 'say! each
"loading module _test..." say!
NB: the json
module is built-in (and does not need to be require
d
or use
d; it can of course still be import
ed).
>>> { x: 42, y: ( 1 2 3 ) } dup json.<- ; json str <- value
"{\"x\":42,\"y\":[1,2,3]}"
>>> json.-> ; json str -> value
{ :x 42 =>, :y ( 1 2 3 ) => }
>>> =
#t
>>> :foo json.<- json.-> ; kwds become strs
"foo"
>>> x: 42 json.<- json.-> ; pairs become lists
( "x" 42 )
>>> , :Foo ( :x :y ) defrecord ; records become dicts
>>> Foo( 1 2 ) json.<- json.->
{ :__koneko_type__ "Foo" =>, :x 1 =>, :y 2 => }
NB: the math
module is built-in (and does not need to be require
d
or use
d; it can of course still be import
ed).
>>> ( :^ :** :sqrt ) :math use-from
>>> math.pi
3.141592653589793
>>> 1.0 math.exp
2.718281828459045
>>> 10.0 math.log ** round
10
>>> 2 10 ^
1024
>>> 2.0 10.0 **
1024.0
>>> 2.0 0.5 **
1.4142135623730951
>>> 2.0 sqrt
1.4142135623730951
>>> -0.0 math.sign
-0.0
>>> 1.0 0.0 / neg math.sign
-1.0
>>> math.pi 0.5 * math.sin
1.0
>>> :math __module-defs__
( :** :^ :acos :acosh :asin :asinh :atan :atan2 :atanh :cos :cosh :exp :log :pi :sign :sin :sinh :sqrt :tan :tanh )
→ Syntax Highlighted Source, → Function Index
... TODO ...