Simplier

From Esolang
Jump to navigation Jump to search
Simplier
Designed by Rignchen
Appeared in 2023
Memory system variables
Dimensions One-dimensional languages
Computational class Turing complete
Reference implementation Simplier
File extension(s) .simple, .simplier

Simplier was originaly made to be easy to read with lines having a max size for them to be allways on the screen and all commands beeing 2 to 4 character long, however it stopped being the case when empty lines where banned wich made the code harder to read

if you want to test the simplier language for yourself, here's a link to the python interpreter

Code's specificity

  • The code is case sensitive
  • The first line is used as a comment, it is the only line that's ignored by the limitations
  • A line of code (comment included) can't be longer than 60 characters
  • A line with more that 2 words can't be repeted
  • A line can't be empty, every line needs to have at least 1 character before the ;
  • Each line needs to end with a ;
  • Everything written after the ; is considered as a comment
  • Characters are written as their ASCII code
  • The $ is used to get the content of a variable, it needs to be placed before the variable name
  • The language supports library importation however it is not recommended to use them as they can denature the code

Variable Types

Name Description
' This type is used to store character
42 This type is used to store numbers
3.14 This type is used to store decimal numbers
? This type is used to store boolean values (yes/no)

Commands

Name Description Syntaxe
var This command is used to declare a variable. var <type> <name> <value>
set This command is used to change the value of a variable, it's also used to calculate and make boolean operations. set <name> <value> [<operation> <value>...]
say This command is used to display a message or a variable value in the console, note that it doesn't add a new line at the end meaning that the next message will be displayed on the same line. say <value> <value> ...
if This command is used to test a value, the code after the if will be executed only if the value is true. if <value:?> <command>
go This command is used to jump to a specific line, if used in a function it will jump to the function line instead of the main code. go <value:42>
fn This can be used to declare a function, every line written between the fn and the end will be considered as the function code, note that it is not possible to declare a function inside another function. fn <name>
call This command is used to execute the content of the function call <name>
lib This command is used to import a library, the library are stored in the "simple_lib" folder next to the interpreter. When possible it is recommended not to use libraries as they can denature the code. lib <name>
in This command is used to get the user input, if the type is ' you can give multiple variable names and each character will be stored in a variable, note that if the input is bigger than the number of variables, the interpreter will return an error. in <type> <name> [<name>... if type = ']
run This command is used to execute another command, the command will be executed after the variables are replaced by their values, note that the value after a variable will be past at the end of the variable value, meaning that you can use multiple variables to create a word, if the last lettre of your word is a variable, you can add 2 spaces to separate the word from the next one. run <value> <command> ...

To take out the content of a variable, simply add a $ before the variable name

Examples

Hello World!

hello world! <- this line is a comment, as well as everything after the ;
fn main;
say 72 101 108 108 111 32; print "Hello"
say 119 111 114 108 100 33; print "world!"
end;
call main; print "Hello world!" by running the main function

this version of the hello world program uses function and multiple lines to print the message as well as comments to show how to use them, however it is possible to write the same program in a single line:

say 72 101 108 108 111 32 119 111 114 108 100 33;

but don't forget that this needs to be on the second line of the file as the first line is used as a comment

Truth Machine

The user can enter a number, if the number is 0 it will print 0, if the number is 1 it will print 1 infinity
var 42 a 0;
var 42 1 1;
var ? b no;
in 42 a;
set b $a = $1;
say $a;
if $b go 7;

Cat program

this is a cat program, it will print out everything you type in
var ' a 0;
var ' b 0;
var ' c 0;
var ' d 0;
var ' e 0;
var ' f 0;
var ' g 0;
var ' h 0;
var ' i 0;
var ' j 0;
var ' k 0;
var ' l 0;
var ' m 0;
var ' n 0;
var ' o 0;
var ' p 0;
var ' q 0;
var ' r 0;
var ' s 0;
var ' t 0;
var ' u 0;
var ' v 0;
var ' w 0;
var ' x 0;
var ' y 0;
var ' z 0;
var ' A 0;
in ' a b c d e f g h i j k l m n o p q r s t u v w x y z A;
say $a $b $c $d $e $f $g $h $i $j $k $l $m $n $o $p $q $r;
say $s $t $u $v $w $x $y $z $A 10;
set a 0;
set b 0;
set c 0;
set d 0;
set e 0;
set f 0;
set g 0;
set h 0;
set i 0;
set j 0;
set k 0;
set l 0;
set m 0;
set n 0;
set o 0;
set p 0;
set q 0;
set r 0;
set s 0;
set t 0;
set u 0;
set v 0;
set w 0;
set x 0;
set y 0;
set z 0;
set A 0;
go 29;

this program is pretty big, this is to give the biggest size possible to the user's input (27 character), it is possible to make it in 5 lines if we don't care about the size of the input:

a smaller version of the cat program that have a maximum input size of 1 character
var ' a 0;
in ' a;
say $a;
set a 0;
go 3;

Looping Counter

.
var 42 max 0;
var 42 count 0;
var 42 count_copy 0;
var 42 0 0;
var ' * 42;
var ? test no;
fn print;
say $*;
set count_copy $count_copy - 1;
set test $count_copy > $0;
if $test go 2;
say 10;
end;
in 42 max;
set count $count + 1;
set count_copy $count;
call print;
set test $count < $max;
if $test go 16;

this program will ask the user for a number and loop until it reaches that number, each loop prints 1 * more than the previous one

Fibonacci sequence

0 1 1 2 3 5 8 ...
var 42 a 0;
var 42 b 1;
say $a 10 $b 10;
set a $a + $b;
set b $b + $a;
go 4;

This print the Fibonacci sequence

Libraries

as the program supports libraries, I think it is important to talk about them here

Time

The time library makes it able to get the current time and make break in the code

Command Description Syntaxe
now This command is used to get the current unix time and store it in a 42 or 3.14 variable now <variable>
zzz This command is used to wait for a specific amount of time, this duration can be in seconds or milliseconds zzz <value>

BP

The bp (or bypass) library makes it able to bypass the limitations of the language, it is not recommended to use it as it highly denature the code

Command Description Syntaxe
cvrt This command is used to convert the content of a variable to another type cvrt <variable> <variable>
add This command is used to add value at the end of the line before itself add <value> <value> ...
del This command is used to delete a variable del <variable>

Files

The Files library can be used to read and write

Command Description Syntaxe
look This command the character at a specific position in a file and store it in a variable look <varriable:'> <value:42> <value> <value> ...
pen This command write a character at the end of a file pen <varriable:'> <value> <value> ...
free This command empty a file, it can also be used to create a new file and/or folder free <value> <value> ...
len This command return the length of a file len <varriable:42> <value> <value> ...