Cookbook
Examples
Small, complete programs. Copy one into a .sym file and run it with sigil run or symc < prog.sym > prog.
hello.sym
((hello, world\n)) > @screen
!!The whole ceremony: text, flow, halt.
fizz.sym
1 > ~$i
?[$i -= 15]{
$i --- 3 > ~$m3
$i --- 5 > ~$m5
?[$m3 == 0]{ ((Fizz\n)) > @screen } -?{
?[$m5 == 0]{ ((Buzz\n)) > @screen } -?{
:wrint { [$i] } ! }}
$i + 1 > ~$i
}?
!!Loops, modulo, and else-if ladders.
fib.sym
:fib { [i64:$n] }
?[$n --= 2]{ $n >!? }
$n - 1 > ~$a :fib { [$a] } ! > ~$lo
$n - 2 > ~$b :fib { [$b] } ! > ~$hi
$lo + $hi >!?
:fib { [10] } ! > ~$r
:wrint { [$r] } ! ::: 55A recursive function calling itself.
echo.sym
:rdall { } ! > ~$buf
:ld64 { [$buf] } ! > ~$len
0 > ~$i
?[$i --= $len]{
:ld8 { [$buf + 8 + $i] } ! > ~$c
:wrch { [$c] } !
$i + 1 > ~$i
}?
!!Read all of stdin and write it back.