Memfuck

From Esolang
Jump to: navigation, search
This article is a work in progress.

Memfuck is a theorized esoteric programming language devised by User:Goosey. Based on brainfuck, Memfuck has many characteristics that resemble brainfuck.

Overview

Much like brainfuck, Memfuck uses a 1D array through which the pointer can move and change values. Unlike brainfuck, Each element in the array is not a single piece of data, but a stack.

A notable difference is that data is not immediately written when incremented, but rather, it's stored as pending data. Pending data is contained in a memory stack. Upon pushing the pending data, the data is popped from the top of the memory stack and pushed to the cell stack, all data in the memory stack will be moved.

Commands

Command Description
> Move the pointer to the right
< Move the pointer to the left
+ Increment the value in the memory stack.
- Decrement the value in the memory stack.
. Retrieve the newest value stored in the stack of the current cell and display it in the output
, Input and push it to the memory stack. Strings are separated into characters and stored from right to left
[ Jumps to the instruction directly after the matching ] if the stacks newest element in the current cell is zero.
] Jump back to the matching [ if cell stack is nonzero. (directives of [] can be changed, explained below)
/ Pop the newest value in the current cells stack.
\ Push the pending data to the top of the current cells stack.
' The following character will be converted to it's ASCII code and pushed to the pending data which is ready to be written.
= Destroy the memory stack.

Brackets

Brackets are used to direct flow of a program, the brackets directives can be changed depending on what values the memory stack contains. The directives are controlled by the memory stack, while the compared values are checked against the current cell, and possibly multiple values in the current cell.

Memory Stack Operation
0 Operate normally and check for non-zero values.
1 Compare the top two items of the cell stack and check for equality.
2 Compare the top two items of the cell stack and check for inequality.
3 Check for a NULL(0) value.
4 Ignore the bracket.

Examples

Hello World

'!\'d\'l\'r\'o\'W\' \'o\'l\'l\'e\'H\ [./]

Cat

+\[,.]

Brackets

Bracket Equality Check

This will loop once, leaving [1] with the data of 1.

+\+\+[>\<-\+]

Related Languages