Grocery List
- Appeared in:
- August 2009
- Paradigm:
- Typing discipline:
- Versions and implementations (Collapse all | Expand all):
Grocery List is an esoteric programming language, in which programs look like, well, grocery lists. Each list item performs a certain command which depends on its first letter and sometimes on the next list item.
Main data structure of the language is a single stack. All operations are done on this stack. The program consists of the header with the name of the shop, an empty line and the actual list of items, each item in a new line.
Language Instructions
S<n>
denotes n-th (0-based) element of the stack, counting from the top. Stack elements used as command arguments are always removed from the stack.
-
a
(add) — pushS0+S1
. -
b
(bring) — remove bottom element and push it on the top. -
c
(copy) — duplicateS0
. -
d
(divide) — pushS0/S1
. -
e
(end loop) — end of the loop. -
f
(flip) — flip elementsS0
andS1
. -
g
(greater than) — push 1, ifS0>S1
, and 0 otherwise. -
h
— execute command which corresponds to charactera+S0%26
. -
i
(input) — read a character from stdin and push its ASCII value. -
j
(jump) — jumpS0
lines forward. -
k
(kill) — remove all elements from the stack. -
l
(loop) — start loop: the loop repeats as long asS0
is non-zero and there are elements in the stack. -
m
(multiply) — pushS0*S1
. -
n
(number) — push the number of characters in the current list item (including whitespace). -
o
(output) — printS0
as a number. -
p
(print) — printS0
as a character. -
q
— no operation. -
r
(remainder) — pushS0 mod S1
. -
s
(subtract) — pushS0-S1
. -
t
(terminate) — terminate program execution. -
u
(unbring) — popS0
and put it to the bottom of the stack. -
v
(value) — push ASCII-code of the next list item (and skip execution of the next line). -
w
— push 100. -
x
— popS0
. -
y
— removeSn
, where n is the number of characters in the current list item. -
z
(zero) — push 1 ifS0=0
, and 0 otherwise.
Examples:
Hello, World!:
Example for versions Progopedia Grocery ListThis example uses v
, n
, c
, w
and p
commands. The rest of list items are skipped, since they are used as arguments for v
command.
Hello, World! supermarket
Vanilla Ice Cream
Honey & Mint Ice Cream
pizza, mushroom and salami
vinegar
eggs, 10
pie with any berries, see what kinds there are
vegetable frozen mix
lamb leg
chicken if no lamb
cod
plaice if no cod
pork steak if you want it
veggie soup
onions
carrots
peas
no more mustard, please! got plenty of it!!!
pair of socks
noodles, I think, with meat, ok?
pasta
Venetian cake
Wax Polish
potato
pumpkin juice
violet onion
rice
popcorn
pudding
watermelon
poultry
Nescafe to take to the office x10
pumpkin
Comments
]]>blog comments powered by Disqus
]]>