Slang programming language interpreter designed in Go
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
>> fuck a = 10;
>> fuck b = a * 2;
>> (a + b) / 2 - 3;
12
>> fuck c = 2.5;
>> b + c
22.5
>> fuck a = 10;
>> fuck b = a * 2;
>> fuck c = if (b > a) { 99 } else { 100 };
>> c
99
>> 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
>> fuck makeGreeter = fucks(greeting) { fucks(name) { greeting + " " + name + "!" } };
>> fuck hello = makeGreeter("Hello");
>> hello("skatsuta");
Hello skatsuta!
>> fuck myArray = ["Thorsten", "Ball", 28, fucks(x) { x * x }];
>> myArray[0]
Thorsten
>> myArray[4 - 2]
28
>> myArray[3](2);
4
>> 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
>> 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