RIfP

From Esolang
Jump to navigation Jump to search

RIfP (Replace If Possible) is an esolang by User:ChuckEsoteric08 inspired by /// and Novice.

Specefication

Memory in RIfP is stored in variables which contain arbitrary-long strings.

Command Description
@x=y Declare variable x with value y.
!x y=z a If there is instance of y in value of variable x replace first instance of it with z and goto label a, else execute next instruction. If z is [] then replace with empty string.
;x Declare label x.
$x Outputs variable x.

Examples

Hello, World!

@hw=Hello, World!
$hw

Truth Machine

@inp=0
;loop
$inp
!inp 1=1 loop

Because this esolang has no input, input is stored into the inp variable by the first line, you can change the first line to change the input.

Computational class

RIfP is Turing-complete because there is Cyclic Tag interpreter in it: Replace 1 in first line with initial data and 011;10;101 on third line with program

@data=^1#
;replaceprogram
@program=^011;10;101#
;interpret
$data
!data ^#=# halt
!program ^0=0^ is0
!program ^1=1^ is1
!program ^;=;^ is;
!program ^#=# loop
;is;
!data ^1=^ interpret
!data ^0=^ interpret
;is0
!data ^1=^1 append0
!data ^0=^0 interpret
;is1
!data ^1=^1 append1
!data ^0=^0 interpret
;append1
!data 0#=01# interpet
!data 1#=11# interpet
;append0
!data 0#=00# interpet
!data 1#=10# interpet
;loop
!data #=# replaceprogram

Another proof is a brainfuck interpreter, which outputs in binary and has no input:

@program=&^++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.#
@data=#^0000000000#
@nest=@#
@zero=0
@one=1
;tobinary
!program ^#=# endbinary
!program ^+=>>>>>>>>[<]@>[@>]<<<<<<<<<[@]^ tobinary
!program ^-=@>>>>>>>>@[<@]>[>]<<<<<<<<<[@]^ tobinary
!program ^>=>>>>>>>>>^ tobinary
!program ^<=<<<<<<<<<^ tobinary
!program ^[=@[>>>>>>>>@[<@]>[>]<<<<<<<<<[@]>>>>>>>>[<]@>[@>]<<<<<<<<<@[@^ tobinary
!program ^]=>>>>>>>>>@<<<<<<<<<]>>>>>>>>>[<<<<<<<<<@>>>>>>>>>@]<<<<<<<<<]^ tobinary
!program ^.=>.>.>.>.>.>.>.>.<<<<<<<<^ tobinary
!program #=# halt
;endbinary
!program &=&^ interpet
;interpret
!program ^#=# halt
!program ^@=@^ flip
!program ^>=>^ next
!program ^<=<^ prev
!program ^[=[^ sloop
!program ^]=]^ eloop
!program ^.=.^ out
!program #=# halt
;flip
!data ^0=^1 interpret
!data ^1=^0 interpret
!program #=# halt
;next
!data ^0=0^ ifoutofbounds
!data ^1=1^ ifoutofbounds
;prev
!data 0^=^0 interpret
!data 1^=^1 interpret
!data #^=#^0 interpret
;ifoutofbounds
!data ^#=^0# interpret
!data #=# interpret
;sloop
!data ^1=^1 interpret
;find]
!program ^#=# halt
!program ^@=@^ find]
!program ^>=>^ find]
!program ^<=<^ find]
!program ^[=[^ [sloop
!program ^]=]^ ]sloop
!program ^.=.^ find]
!program #=# halt
;[sloop
@nest @=@* find]
;]sloop
@nest @# interpret
@nest *=[] find]
;eloop
!data ^0=^0 interpret
;find[
!program #^=# halt
!program @^=^@ find[
!program >^=^> find[
!program <^=^< find[
!program [^=^[ [eloop
!program ]^=^] ]eloop
!program .^=^. find[
!program &^=& halt
;]eloop
!nest @# endeloop
!nest *=[] find[
;endeloop
!program ^[=[^ interper
;0out
!data ^0=^0 0out0
!data ^1=^1 0out1
!program #=# halt
;halt