Surtic

From Esolang
Jump to: navigation, search

Surtic (pronounced either "sour tick" or just "sertik") is a programming language designed by me, User:Digital Hunter. It was at first based off of and inspired by BF, but has evolved to be quite different. At first, it was super confusing to use, but now after some changes it's less confusing to use so I'm not entirely sure if it qualifies as an esolang anymore.

How it works

Basically there are three infinite tapes of variables in which the user can store data, the c, s, and b groups.

The c variable group

These are your integer "cells." Each cell can in theory take on any integer value (since there is no division operator that I know of). The call numbers go from 0 up (so the first cell is cell zero). Things you can do:

c#+  Increment that cell.  Ex. c0+
c#-  Decrement that cell.  Ex. c0-
ic#  Take an input to that cell.  Ex. ic0
pc#  Print the value of that cell.  Ex. pc0

The b variable group

These are boolean variables. They can be either 1 (true) or 0 (false). They are all 0 by default. The call numbers go from 1 up (so the first boolean is boolean 1) Things you can do:

!b#                   Flip truth value of that boolean (changes from 0 to 1 and 1 to 0).  Ex. !b1
?((c#){op}(c#)-(b#))  TRUE/FALSE where you take two numbers by calling two cells and relate them using {op} which can be <<, >>, ==, !=, <=, or >=, stored to the selected boolean.  Ex. ?(c0<c1-b1)
?((s#)=(s#)-(b#))     TRUE/FALSE where you can take two strings and see if they are the same or not.  Ex. ?(s1=s3-b2)

The s variable group

These are strings. The call numbers go from 1 up (so the first string is string 1). Things you can do:

"text"-s#  Put text in a string.  Ex. "Thomas thinks this is dumb"-s1
is#        Take an input to a string.  Ex. is1
ps#        Print whatever's in that string.  Doesn't work if there's nothing in that string.  Ex. ps1

Loops & Blocks

Loops and blocks that exist:

[=(c#)   Opens an s loop.  This repeats the code inside by the number of times stated by the value called cell.  Ex. [=(c0)*randomcodehere*
[-(c#)   Opens a d loop.  This repeats the code inside as long as the called cell is greater than 0, decrementing its value just before the repeat.  Ex. [-(c0)*randomcodehere*
[(b#)    Opens a while loop.  Repeats the code inside as long as the called boolean is 1.  Ex. [(b1)*randomcodehere*
]        Closes a loop.  Ex. *randomcodehere*]
{(b#)    Opens an if/then block.  Runs the code inside if the called boolean is 1.  Ex. {(b1)*randomcodehere*
}{!(b#)  Opens an else/if/then block.  Must come after an if/then or another else/if/then block.  Ex. *randomcodehere*}{!(b1)*randomcodehere*
}{!      Opens an else block.  Must come after an if/then or an else/if/then block.  Ex. *randomcodehere*}{!*randomcodehere*
}        Closes a block

Some example programs

Hello world

"Hello world"-s1ps1

Infinite Cat

!b1[(b1)is1ps1]

Fibonacci sequence

c1+!b1[(b1)pc0[=(c1)c0+]pc1[=(c0)c1+]]

Factorial

ic0c1+[-(c0)[=(c1)[=(c0)c2+]][-(c1)][-(c2)c1+]]pc1

Add two numbers, print the result, and clear all the cells

ic2ic1[-(c1)c0+][-(c2)c0+]pc0[-(c0)]

Subtract two numbers, print the result, and clear all the cells

ic0ic1[-(c1)c0-]pc0[-(c0)]

Multiply two numbers, print the result, and clear all the cells

ic0ic1[-(c1)[=(c0)c2+]][-(c0)]pc2[-(c2)]

Divide two numbers, print the quotient and the remainder, then clear all the cells

ic0ic1!b1[(b1)[=(c1)c0-]c2+?(c0>>c1-b1)]pc2pc0[-(c2)][-(c1)][-(c0)]