STRong

From Esolang
Jump to navigation Jump to search

STRong is a language made by User:Qawtykit to add more features to a string-rewriting paradigm.


Program Structure

Programs in STRong start with the initial string, followed by a newline. Then you write the program, which is read from top to bottom. If a find/replace finds multiple strings, all of them are replaced.

Commands and Expressions

Each command is ended with a newline

Command Description Example usage
'string'replacement Find and replace on the initial string 'asdf'fasd
:string:n set variable n to string :asdf:fasd
!string!replacement!v find and replace on variable v !asdf!tyrant!fasd
.n define jump point named n .asdf
^string^n jump to jump point n if string is found in the initial string ^fasd^asdf
*...* comment *this will be ignored*

Jumping to label "end" terminates the program. These are expressions placed within a string, they also work in the initial string:

Expression Description Example usage
? return line from input 'p'? *replace p with input*
# return entire initial string !#!!*clear initial string*
any character, does not work in initial string '!☼☼☼☼d'!☼☼☼☼f *replacement from distance away*
str∞str any amount of space can be between two strings '[∞]'asdf *check for balanced brackets*
(n) return unicode character corresponding to n (10)*newline*
~ concatenate two string expressions (10)~#
n[string&string] n% chance to return string on left, else return string on right 50[heads&tails] *coin flip*
{string} string in curly brackets will not be removed when replaced, instead replacement will be placed to the right of it '{a}'b *infinite loop*
<string> string will be output to the console '@'<Hello, World!>

Examples

Truth-machine

i
'i'? *Ask for input*
^0^zero *If the input is 0:*
^1^one *Whereas if the input is 1:*
^#^end
.one
'{i}'<1> *Output 1*
^1^one *Repeat infinitely*
.zero
'i'<0> *Output 0.*
.end *Terminate program*

Unary subtraction

a-b
'a'? *input sequence of 0s for unary number*
'b'?
'-∞0'1 *convert every 0 on right into 1*
.loop
'01'
^01^loop
'1'0
0'<0>