SQRT

From Esolang
Jump to: navigation, search

SQRT is a programming language with the theme of algebra by User:ZirconiumX.

Basic features of SQRT

All SQRT statements are in the format

<variable>=<variable><operand><variable>

or maybe

<variable>=<number><operand><number>

where <operand> can be / * + - & | ^ %

(divide, times, plus, minus, AND, OR, XOR, and modulus respectively)

SQRT statements can be grouped as one statement

o=20+20+15+15+2

You can use any letter or symbol (but not a number) except o(utput) and i(nput) and v (you'll see why in a bit). So the above example would print

H

to standard output.

You can also group statements even further by using

v/

and

_

where v/ indicates the start of a statement and _ indicates the next statement. (No, there isn't an end marker, simply continue until a newline is reached)

Advanced features of SQRT

@

means a comment.

$<number>

is a loop that repeats <number> of times. (equivalent to a (int i = 0; i < <number>; i++) loop)

!<numberstart><numberend><variable>

is a loop that repeats <numberend>-<numberstart> times, and allows you to use <variable>(equivalent to a (int i = <numberstart>; i < <numberend>; i++) loop)

~

breaks out of the loop.

Hello World examples in SQRT

Basic

o=72+0
o=101+0
o=108+0
o=108+0
o=111+0
o=32+0
o=87+0
o=111+0
o=114+0
o=108+0
o=100+0
o=33+0
o=10+0

would print

Hello World!

Intermediate

o=v/72+0_101+0_108+0_108+0_111+0_32+0_87+0_111+0_114+0_108+0_100+0_33+0_10+0

would also print

Hello World!

Advanced

$i
 o=v/72+0_101+0_108+0_108+0_111+0_32+0_87+0_111+0_114+0_108+0_100+0_33+0_10+0

would print

Hello World!

depending on the number you wrote to the program