Sign inSign up

rootmos/silly-k-base

By rootmos

Updated over 9 years ago

Base image for silly-k

Image
0

10K+

rootmos/silly-k-base repository overview

silly-k

Build status

silly-k is an experimental hobby language inspired by K and APL.

The silly prefix is meant to indicate that this is project is nothing more than an experiment to see how these languages would perform when described in lambda calculus terms.

The compiler is written for the nanopass framework using the following structure:

  • the K-like, APL inspired, syntax is translated into something like simply typed lambda calculus which is used to resolve the overloaded symbols from K,
  • after that, the types are thrown away and is compiled to Malfunction or to Scheme (which is used mainly for quick tests and the REPL).

Usage

Easiest way to play around with it is to run the Docker image:

docker run --rm -it rootmos/silly-k

which starts the REPL.

Examples

Here's some examples of the syntax (taken directly from the tests

CodeStdinStdout
]77
]1 2 31 2 3
]1=20
]2=21
]2<31
]2<20
]3<20
]2>30
]2>20
]3>21
]~1=21
]~2=20
]~01
]~70
](1=2)|2=30
](1=2)|2=21
](2=2)|2=31
](2=2)|3=31
](1=2)&2=30
](1=2)&2=20
](2=2)&2=30
](2=2)&3=31
]2&32
]2|33
]1+23
]1+2 33 4
]1 2+3 44 6
]1 2+34 5
]2-3-1
]1-(-2)3
]1 2-3 4-2 -2
]@-7-7
]@-(-2)2
]1-2 3-1 -2
]1 2-3-2 -1
]2*36
]1 2*33 6
]4*2 38 12
]1 2*3 43 8
]@{w+1}'1 2 32 3 4
]@{1-w}'3 4 5-2 -3 -4
]2{a+w}'3 4 55 6 7
]2{w-a}'3 4 51 2 3
]2+'3 4 55 6 7
]2-'3 4 5-1 -2 -3
]@+/1 2 36
]@-/1 2 32
]@{w-a}/1 2 30
]1:77
]0:1 2 31 2 3
](1:)+178
]1+0:1 2 32 3 4
](0:)+1:2\n1 2 33 4 5
](1=1;2;3)2
](1=2;1 2;3 4)3 4
]7{w=1;w;a}11
]7{w=1;w;a}87
]{w=1;w+1;w=2;w+2;w+3}12
]{w=1;w+1;w=2;w+2;w+3}24
]{w=1;w+1;w=2;w+2;w+3}36
]{w=1;w+1;w=2;w+2;w+3}47
](1=1;2;3)2
]{w=0;0;w+_f(w-1)}621
]{w=1;1;w=2;1;(_f(w-2))+_f(w-1)}1:713
]x+x:714
](x:1)+x:23
]x+(x:1)+x:24
]x+x{x:1+a-w}x:23

Tag summary

Content type

Image

Digest

Size

357.9 MB

Last updated

over 9 years ago

docker pull rootmos/silly-k-base