SLet (Old 3)

From Esolang
Jump to navigation Jump to search

<- Older version | Newer version ->

SLet 3
Designed by User:I am islptng
Appeared in 2025
Computational class Turing-complete
Reference implementation Python
Influenced by Lua
File extension(s) .slet



SLet 1 has no clear type, SLet 2 has limited commands, so the author created SLet 3!

Data types

In this esolang, there is 5 data types.

Number: Fraction. Size is unlimited. Division by 0 is NaN.
Boolean: true or false.
Pair: A pair of objects. One former value and one latter value.
Lambda: Just a lambda function.
Set: The most common data type. Objects in a set is always sorted. Boolean < Number < Pair < Set < Lambda.

Commands

==== Flow Control
for          | For every object in set A, store it in variable named B, and execute lambda C.
while        | While boolean A is True, execute lambda B.
do           | Start define a lambda. End with "all".
call         | Executes lambda A.

==== Input/Output
get-char     | Get a character input.
put-char     | Print a character.
input        | Get a number input.
print        | Print an object.
decprint     | Print a fraction as decimal to the B'th digit.

==== Data structures and calculations
match        | Make a pair. Returns (A,B).
combine      | Makes a set with various objects by union. End with "all".
opposite     | Not boolean A. Negate number A.
swap         | Swap the two objects in pair A. Swap the numerator and the denominator in number A.
former       | Former object of pair A. Numerator of number A.
latter       | Latter object of pair A. Denominator of number B.
pack         | Pack object A into a set.
exist        | True if object A is a subset of object B.
reveal       | Pick a random object from set A. Randomly choose an integer between the 2 numbers in pair A.
first        | Returns the smallest item in a set.
add          | Does addition between numbers.
or           | Does OR between booleans.
multiply     | Does multiplication between numbers.
and          | Does AND between booleans.
intersect    | Does intersection between sets.
divide       | Does division between numbers.
floordiv     | Does floor division between numbers.
modulo       | Does modulo between numbers.
range        | Python "range(A,B,C)". Returns sets.
filtrate     | For every object in set A, store it in variable named B, if C is false, throw away the item.
size         | The size of set A.

==== Variables
let          | Set the variable named A to B.
==== Constants
true, false, empty, nan, infinity

Strings can be written in double quotes. Use backslash for escape(\q is used for double quotes.). Comments are written between parentheses.

Examples

Hello world

for "Hello, world!" i do put-char latter i all

A+B problem

print add input input

Truth Machine

let a input let l do print 1 all while a l print 0

Calculate pi

Initialize:

let a 2 let b 0 let c 1 let i 1 let f do let t add multiply i 2 1 let b add a b let b multiply b t let c multiply c t let a multiply a i let i add i 1 print divide b c all

Each iteration, run:

call f