Pretzl

Editor

Console

Cheatsheet

Basic Values

Numbers

42, -3.14, 0

Strings

"hello world"

Arithmetic

+ - * / %

+ 1 2    → 3
* (+ 1 2) 3    → 9
% 7 3    → 1

Comparisons

< > <= >= ==
(< 5 10)    → 1 (true)

Variables & Functions

set

set x 10
set pi 3.14159

lambda

lambda x (* x x)
lambda (x y) (+ x y)

Control Flow

if

if (> x 5) "big" "small"

while

while (< i 10) (inc i)

for

for (set i 0) (< i 5) (inc i) (print i)

begin

begin (print "a") (print "b") (print "c")

inc

inc i

dec

dec j

Input/Output

print

print "hello"
print (+ 1 2)

input

set name (input)
set age (input)

Lists

list

list 1 2 3 4 5
set nums (list)
set nums [1 2 3]
set empty []

append

append nums 42

sort

sort nums

length

length nums

get

get nums 0

Strings

concat

concat "hello" " " "world"

type

type "hello"    → "string"

Function Calls

Syntax

(function arg1 arg2 ...)
(factorial 5)
(lambda x (* x x) 4)

Truth Values

True

1, any non-zero number

False

0