SLet (Old 2)

From Esolang
Jump to navigation Jump to search

<- Older version | Newer version ->



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.

Tutorial

Part 1: Basics

Data structures

Number

Simply enough, stores a number, whether it is a fraction(we use fraction instead of decimal) or integer.

Pair

Stores 2 values, one "former", one "latter".

Set

The main data type. It is always sorted from small to large.(Boolean<Number<Pair<Set<Lambda)

Lambda

You can define functions using this.

Commands

Flow control

* takes 3 arguments, set val op

For every val in set, execute op.

~ takes 2 arguments, cond op

While cond is True, do op.

\ takes 1 argument, op

Directly store op as an instruction instead of executing it.

@ takes 1 argument, op

Executes op.

Arithmetic

- and / takes 1 argument.

- negates it and / divides 1 by it.

+ takes 3 argument, lvl arg1 arg2

lvl=0 returns arg1+arg2, lvl=1 does multiplication, lvl=2 does power, and lvl>=2 does Gardner Arrows.

Sets and Pairs

? takes 3 argument, set val cond.

For every val in set, if cond is False, waste the item. Returns the rest.

| and & takes various arguments, end with !.

| does union and & does intersect.

% takes 2 arguments, former latter

Makes a pair from the given two.

^ and _ takes 1 argument.

^ packs the argument into a set while _ returns the smallest value in a set.

< and > takes 1 argument.

< returns former and > returns latter.

Original description

Data types

  1. 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.
  2. Set: Just as it says.
  3. Pair: Stores two values.
  4. 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



Computational class

This esolang is Turing Complete. It do has "while" and data structures, which means it can simulate brainfuck.