Merucik

From Esolang
Jump to navigation Jump to search

Merucik is a Brainfuck derivative made by User:Conor O'Brien that adds some minor functionality to aid the programmer in coding. Merucik programs operator on a right-open, theoretically-unbound tape. Each cell can contain an arbitrary number.

Instructions

Merucik contains all the commands found in Brainfuck, and features the following added commands:

Command Operation
" Begins string parsing. Will write ASCII characters to the strip until another " is met. Uses ^ as an escape character.
: Outputs the current cell's value as a number
; Takes numeric input
~ Copies the current cell's value to the register (a single-celled container separate from the strip.)
# Writes the value from the register to the current cell.
N Writes a linefeed to the current byte and increments pointer.
S Adds 32 to the current byte.
F<name>{...} Defines a function <name> that executes ... upon being called. (<name> can be empty.)
f<name>{N} Calls function <name> N (or one) times.
(...) Ignores ... (comment).
\ Terminate program
+*% Performs (current cell value) OP (previous cell value), setting the result to the register.
/ Sets the current cell's value to 1/(current cell's value)
- Sets the current cell's value to -(current cell's value)

Example Programs

Hello, World! (1)

"Hello, World!"[.<]

Hello, World! (2)

This can probably be simplified more, but here is one using functions.

F{++++++++++++}++++++++SS.S++.>f{}..+++.~>Sf{}.>S.SSf{2}-.#.+++.------.>SSf{3}.>S+.
F{++++++++++++} (+12)
++++++++SS.          (H)
S++.                 (e)
>f{}..               (ll)
+++.~                (o; store to register)
>Sf{}.               (right and ,)
>S.                  (right and  )
SSf{2}-.             (w)
#.                   (o)
+++.                 (r)
------.              (l)
>SSf{3}.             (d)
>S+.                 (!)

Computational Class

Merucik is Turing-complete by a trivial reduction to Brainfuck.