Slug
Jump to navigation
Jump to search
Slug is a programming language which can only do things a finite number of times, meaning that you can't make infinite loops. Slug also needs to be compiled.
Syntax
You can store values in lines. Like this:
1 #0
Line one has the value of 0. You can also store strings in lines:
1 "Hello world"
You can label lines using the ':' command.
1 str: "Hello world"
To print you use the .out command:
1 "Hello, world" .out
But what if we want to print a variable, how do we get a variable from a line? we use the @ command.
1 str: "Hello world" 2 @str .out
To store a bool you use '~'
The basic syntax is modifier1 value modifier2 .
Control flow
The '.if' function takes a bool, a line using the '\', and a number, like this:
1 n: "H" .out 2 b: ~true 3 .if @b, \n, 10 ; if b is true repeat line n ten times
You use '.in' for input
Programs
A+B problem
1 a: .in 2 b: .in 3 sum: @a + @b 4 @sum .out