SLet
If you want to read the old version, please go to SLet (Old).
This is a completely new version from the same people.
SLet is an esolang created by islptng. The title, is a mixture of Set and Let.
Set means that this esolang is based on sets; and
Let means that you uses a "Let" command to give a variable a value Note: It was "Let" in the old version, but now I simplified it.
Data types
- Number: Real numbers, but no e. For example, 114514, 3.14159, 0, -3. Something called "1e+10" is not allowed, you have to write "10000000000" or use commands.
- Set: Just as it says.
- Pair: Stores two values.
- Instruction: Stores an instruction.
An empty set is False. 0 is False. (False, False) is False. True otherwise.
Note that the Set is sorted from small to big. Pair is treated as its former value.
Lists
Because we have only sets, lists are stored as Set<Pair<Number,Any>>, where in the pair, former is index, and latter is value. They are 0-indexed.
Commands
Parentheses () are used for comments, include multiline one. Basic commands: #<variable name>,<value> Sets a variable's value to it. @<instruction> Executes instruction, or it can be lists. *<set>,<var>,<instructions> for every value in the set,sets variable var to the value, and execute instructions. ~<condition>,<instructions> while condition is True, execute instructions. ; Input a character. :<value> prints a character. ' inputs a number. `<value> prints a number. |<set 1>,<set 2>,<etc ...>! Union of the given sets. &<set 1>,<set 2>,<etc ...>! Intersect of the given sets. ^<value> Packs the value into a set. For example, ||1,2,3!,5! returns {1,2,3,5}, but ||1,2,3!,^5! returns {1,2,3,{5}}. _<set> Unpacks a set and returns its first value. If the parameter is a number, return floor(x). If the parameter is pair, return randint(former, latter). =<set> Returns the size of given set. ?<set>,<var>,<condition> Filter. Assigns variable with each value of the set, calculates the condition, if result is False, waste current value. +<level>,<number 1>,<number 2> number 1 operates number 2. operates is <level>, 0=add; 1=multiply, 2=power, etc. -<number> negates number. /<number> returns 1 divided by the number. %<former>,<latter> makes a pair. <<pair> returns the former value of the pair. ><pair> returns the latter value of the pair. $<set 1><set 2> returns 1 if set 1 is a subset of set 2. [<value>,<value>,<etc ...>! returns a list. "<text>! returns a list of ASCII numbers. Escape sequence is allowed. ]<from>,<to>,<step> generate a set including those numbers, from is included but to is not. \<code> treat <code> as instruction instead of executing it.
Examples
Hello World
#t,"Hello, World\!\n!,*t,c,[:>c!
Graham's number
#g,+5,3,3,*]1,64,1,i,[#g,++0,g,1,3,3!,`g
A+B problem
`+0,','
Cat program
#in,[:;,@in!,@in
Fibonacci
replace 50 with the number you want.
#a,0,#b,1,*]0,50,1,i,[#c,+0,a,b,#a,b,#b,c,`a!
Compute Pi
#a,2,#b,0,#c,1,*]1,52,1,i,[#t,+0,+1,2,i,1,#b,+1,+0,a,b,t,#c,+1,c,t,#a,+1,a,i!,`+1,b,/c
Other algorithms
Computational class
This esolang is Turing Complete because 3-cell BF can be translated into this.
- put
[#l,[0,0,0!,#p,0,
at the beginning - "<" =
#p,+0,p,-1,
- ">" =
#p,+0,p,1,
- "[" =
~>?l,t,$<t,^p,[
- "]" =
!,
- "+" =
#l,|>?l,t,+0,1,-$<t,^p,%p,+0,>?l,t,$<t,^p,1!,
- "-" =
#l,|>?l,t,+0,1,-$<t,^p,%p,+0,>?l,t,$<t,^p,-1!,
- "," =
l,|>?l,t,+0,1,-$<t,^p,%p,;!,
- "." =
:>?l,t,$<t,^p,
- put
#p,0!
at the end
Interpreter
A quite buggy Python library and console is available here, or if you are not convenient to use Python, try it online!