Giter Site home page Giter Site logo

silly-k's Introduction

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

silly-k's People

Contributors

rootmos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.