We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Gridify

From Esolang
Jump to navigation Jump to search

Gridify is an esolang by User:Cordership based on Befunge.

Instructions

Instruction Definition
> Move code pointer right.
< Move code pointer left.
^ Move code pointer up.
v Move code pointer down.
~ Input a character and push it into the stack.
& Input an integer and push it into the stack.
. Pop the number at the top of the stack, output it as an integer.
, Pop the number at the top of the stack, output it as an ASCII character.
_ Horizontal If: Pop top of stack, go right if value=0, otherwise go left.
| Vertical If: Pop top of stack, go down if value=0, otherwise go up.
` Horizontal If reverse.
x Vertical If reverse.
? All-directions If: Pop top of stack, if value=1 go up, if value=2 go right, if value=3 go down, if value=4 go left.
R Go in a random direction.
0-9 Push the corresponding integer into the stack.
"[string]" Push string into the stack.
@ Halt program.
: Pop top of the stack and store it in the code pointer.
; Push the code pointer's contents into the stack.
+ Pop the two topmost numbers a and b in the stack, push the result of a+b.
- Pop the two topmost numbers a and b in the stack, push the result of b-a.
* Pop the two topmost numbers a and b in the stack, push the result of a*b.
/ Pop the two topmost numbers a and b in the stack, push the result of the integer division b/a.
% Pop the two topmost numbers a and b in the stack, push the remainder of the integer division a/b.
h Pop the two topmost numbers a and b in the stack, push the result of b^a.
# Discard the code pointer's contents.
/text/ One-line comment.
$ Pop top of the stack, duplicate it: one copy gets pushed back into the stack, the other goes into the code pointer.
w Pop the code pointer's contents, duplicate it: one copy goes into the stack, the other stays in the code pointer.
k Pop the two topmost numbers a and b in the stack, push a into the stack b times.
n Pop all of the stack's contents and print them from top to bottom as integers.
r Pop all of the stack's contents and print them from top to bottom as ASCII characters.
o Increment the code pointer's contents by 1.
a Duplicate top stack value.
p Skip the command right ahead of the code pointer in its direction.
\ Swap top stack values.
z Move the code pointer in a random direction.
b Pop top of stack and discard.
G A "get" call (a way to retrieve data in storage). Pop two values y and x, then push the ASCII value of the character at that position in the program. If (x,y) is out of bounds, push 0
P A "put" call (a way to store a value for later use). Pop three values y, x and v, then change the character at the position (x,y) in the program to the character with ASCII value v
g Greater than: Pop two values a and b, then push 1 if b>a, otherwise zero.
L Less than: Pop two values a and b, then push 1 if b<a, otherwise zero.
[ Rotate the top three items on the stack clockwise.
] Rotate the top three items on the stack counterclockwise.
m Mirror, reverse current direction.
  1. Everything else is NOP.

Programs

Hello, World!

"!dlroW ,olleH">,v
               ^ <

Hello, World! 2

89*!54*5*1+!34*9*!34*9*!66*1+3*!56+4*!25h!47*1+3*!66*1+3*!66*2+3*!34*9*!54*5*!65*3*!@

Hello, World! 3

"!dlroW ,olleH"r@

One time cat

,.

Cat program

,>.,v
 ^  <

Truth-machine

, >v
   v
v1<_0.@
>.^

A+B problem

&&+.

Looping counter

67*0:>owkr52*,v
     ^        <

4-function calculator

&&&v @
   p .
   >+^
  v?-^
  /*
  >> ^