Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
c
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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:

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

which starts the REPL (under rlwrap).

Examples

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

Code Stdin Stdout
]7 7
]1 2 3 1 2 3
]1=2 0
]2=2 1
]2<3 1
]2<2 0
]3<2 0
]1<1 2 3 0 1 1
]1 2 3>2 0 0 1
]2>3 0
]2>2 0
]3>2 1
]{w>1}'1 2 3 0 1 1
]3>1 2 3 1 1 0
]1 2 3>2 0 0 1
]1=2 0
]2=2 1
]{w=2}'1 2 3 0 1 0
]1 2 3=3 0 0 1
]1=1 2 3 1 0 0
]~1=2 1
]~2=2 0
]~0 1
]~7 0
]~2=1 2 3 1 0 1
](1=2)|2=3 0
](1=2)|2=2 1
](2=2)|2=3 1
](2=2)|3=3 1
](1=2)&2=3 0
](1=2)&2=2 0
](2=2)&2=3 0
](2=2)&3=3 1
]2&3 2
]2|3 3
]1+2 3
]1+2 3 3 4
]1 2+3 4 4 6
]1 2+3 4 5
](1=1)+(2=2) 2
]1+(2=2) 2
]1+2=1 2 3 1 2 1
](2=1 2 3)+1 1 2 1
]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*3 6
]1 2*3 3 6
]4*2 3 8 12
]1 2*3 4 3 8
]!1 0
]!4 0 1 2 3
]*1 2 3 1
]*0=0 1 1
]*0=1 0 0
](*0=0 1;7;8) 7
](*0=1 0;7;8) 8
]#1 2 3 3
]#1 2 3 4 4
]4#1 2 1 2 1 2
]3#1 1 1 1
]1 2 3@1 2
]((2=1 2 3)@1;7;8) 7
]((2=1 2 3)@2;7;8) 8
]1 2 3@0 2 1 3
]&1 2 3 0 1 1 2 2 2
]7 8@&2 3 7 7 8 8 8
]{w+1}'1 2 3 2 3 4
]{1-w}'3 4 5 -2 -3 -4
]2{a+w}'3 4 5 5 6 7
]2{w-a}'3 4 5 1 2 3
]2+'3 4 5 5 6 7
]2-'3 4 5 -1 -2 -3
]{w@1}'{+w}'1 2 3 2 3 4
]{w@1}'{-w}'1 2 3 0 -1 -2
]+/1 2 3 6
]-/1 2 3 2
]{w-a}/1 2 3 0
]+/2<!5 2
]&/0<1 2 3 1
]&/0<1 0 3 0
]1: 7 7
]0: 1 2 3 1 2 3
](1:)+1 7 8
]1+0: 1 2 3 2 3 4
](0:)+1: 2\n1 2 3 3 4 5
](1=1;2;3) 2
](1=2;1 2;3 4) 3 4
]7{w=1;w;a}1 1
]7{w=1;w;a}8 7
]{w=1;w+1;w=2;w+2;w+3}1 2
]{w=1;w+1;w=2;w+2;w+3}2 4
]{w=1;w+1;w=2;w+2;w+3}3 6
]{w=1;w+1;w=2;w+2;w+3}4 7
](1=1;2;3) 2
]{w=0;0;w+_f(w-1)}6 21
]{w=1;1;w=2;1;(_f(w-2))+_f(w-1)}1: 7 13
]x+x:7 14
](x:1)+x:2 3
]x+(x:1)+x:2 4
]x+x{x:1+a-w}x:2 3

About

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

Topics

Resources

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.