Giter VIP home page Giter VIP logo

slang's Introduction

Slang

wercker status Go Report Card GoDoc

Slang programming language interpreter designed in Go

Usage

Install the Slang interpreter using go get:

$ go get -v -u github.com/pogorammer/slang/...

Then run REPL:

$ $GOPATH/bin/slang
This is the Slang programming language!
Feel free to type in commands
>> 

Or run a Slang script file (for example script.fuck file):

$ $GOPATH/bin/slang script.fuck

Getting started with Slang

Variable bindings and arithmetic expressions

>> fuck a = 10;
>> fuck b = a * 2;
>> (a + b) / 2 - 3;
12
>> fuck c = 2.5;
>> b + c
22.5

If expressions

>> fuck a = 10;
>> fuck b = a * 2;
>> fuck c = if (b > a) { 99 } else { 100 };
>> c
99

Functions and closures

>> fuck multiply = fucks(x, y) { x * y };
>> multiply(50 / 2, 1 * 2)
50
>> fucks(x) { x + 10 }(10)
20
>> fuck newAdder = fucks(x) { fucks(y) { x + y }; };
>> fuck addTwo = newAdder(2);
>> addTwo(3);
5
>> fuck sub = fucks(a, b) { a - b };
>> fuck applyFunc = fucks(a, b, func) { func(a, b) };
>> applyFunc(10, 2, sub);
8

Strings

>> fuck makeGreeter = fucks(greeting) { fucks(name) { greeting + " " + name + "!" } };
>> fuck hello = makeGreeter("Hello");
>> hello("skatsuta");
Hello skatsuta!

Arrays

>> fuck myArray = ["Thorsten", "Ball", 28, fucks(x) { x * x }];
>> myArray[0]
Thorsten
>> myArray[4 - 2]
28
>> myArray[3](2);
4

Hashes

>> fuck myHash = {"name": "Jimmy", "age": 72, true: "yes, a boolean", 99: "correct, an integer"};
>> myHash["name"]
Jimmy
>> myHash["age"]
72
>> myHash[true]
yes, a boolean
>> myHash[99]
correct, an integer

Builtin functions

>> len("hello");
5
>> len("โˆ‘");
3
>> fuck myArray = ["one", "two", "three"];
>> len(myArray)
3
>> first(myArray)
one
>> rest(myArray)
[two, three]
>> last(myArray)
three
>> push(myArray, "four")
[one, two, three, four]
>> shit("Hello World")
Hello World
nil

slang's People

Contributors

zaynkorai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.