backpackr

From Esolang
Jump to navigation Jump to search

Introduction

backpackr is a stack-based themed language that uses a two-dimensional plane of stacks to store information. The backpacker is a pointer with a bag (an additional stack) that can move around in the two dimensional stack space, placing and picking up integers.

Documentation

the current implementation of backpackr has the following commands:

command action
w move the pointer one stack forward
s move the pointer one stack backward
a move the pointer one stack left
d move the pointer one stack right
p place an object on the stack the backpacker is standing on. If p is followed by an integer, it places that integer down. Otherwise, the top item in the backpack is popped. If the backpack is emptied, the command is ignored
l pop an item off the stack the backpacker is standing on. if the ground is empty, ignore
e empty the contents of the bag out onto stdout
t pop the topmost item from the bag and write it to stdout
c peeks at the top item in the bag, then adds it to the top item in the stack that the backpacker is standing on. If that stack is empty, then push it on.
r same as c, but instead subtract
g empty the bag onto the stack that the backpacker is standing on
v jump down n lines. must be followed by an integer
^ jump up n lines. must be followed by an integer
m take a single integer from stdin and push it onto the backpack
h go home, or stack 0,0
f pop and compare both the bag and the stack that the backpacker is standing on. If they match, continue. If not, skip to the next line
u examine the stack that the backpacker is standing on. If it is empty, continue. Otherwise, skip to the next line.
x take the contents of the bag and look for a file with that name. Run the backpacker on that path using the same terrain as the parent file
k destroy the contents of the bag
z destroy the contents of the stack that the backpacker is standing on

Syntax

Valid Characters

backpackr ignores any characters other than the above commands and numerals, including spaces, so using uppercase comments, arrows, and punctuation is useful when writing programs. Newlines, however are used by the jump and conditional commands, so being conscious of those is necessary.

Errors

Anything that is invalid is ignored by backpackr. If a command cannot be executed, the program moves on.

Printing Numbers

When an integer is enumerated to stdout, it, by default will display the ascii-encoded value of that integer. In order to display an integer, prefix it with a 0.

Example Programs

Hello, world!

p10lp33lp100lp108lp114lp111lp119lp32lp44lp111lp108lp108lp101lp72le

Fibonacci Sequence

Endlessly enumerating iterative fibonacci sequence

ap0dp1
alcp0le
dlcp0lp10le
lcacwgslcp0lp10le
lcdcwgslcp0lp10le
^2
p10le

Recursive fibonacci using two files: hf.bpkr

p10lp98lp105lp102le  PRINT "ENTER A NUMBER"
p10lp58lp114lp101lp98lp109lp117lp110l
p32lp97lp32lp114lp101lp116lp110lp101le
wap1dp0ssamp INITIATE CONDITIONAL VALUES AND ITERATOR
h 
ap0ddp1      SETUP FIB ARGUMENTS
h
p102lx       CALL F

f.bpkr

hwlcssalcpfv6            CHECK CONDITIIONAL
hwalcdck                 INCREMENT COUNTER
hp10lalc(p0l)elcddckh      PRINT AND ADD(QUASI N-TWO) ZERO PUSHED TO PRINT INTEGER(IN PARENS)
wlcssalcpfv3             CHECK CONDITIIONAL
hwalcdck                 INCREMENT COUNTER
hp10ldlcp0lelcaackh      PRINT AND ADD(QUASI N-ONE)
p102lx                   CALL SELF

The program f takes advantage of the inherent scopelessness of backpackr and access pre-stored stacks as parameters.

Turing Completeness

Although backpackr is not formally proven Turing-Complete, it has all the attributes of a Turing-complete language. Informal evidence of Turing-completeness:

  • backpackr's ability to emulate k-stack PDAs, which are proven to be equivalent in robustness to Turing machines.
  • the infinite stack field that the backpacker operates on.

External Resources