Grocery List

Appeared in:
August 2009
Paradigm:
Typing discipline:
Versions and implementations (Collapse all | Expand all):
Programming language

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) — push S0+S1.
  • b (bring) — remove bottom element and push it on the top.
  • c (copy) — duplicate S0.
  • d (divide) — push S0/S1.
  • e (end loop) — end of the loop.
  • f (flip) — flip elements S0 and S1.
  • g (greater than) — push 1, if S0>S1, and 0 otherwise.
  • h — execute command which corresponds to character a+S0%26.
  • i (input) — read a character from stdin and push its ASCII value.
  • j (jump) — jump S0 lines forward.
  • k (kill) — remove all elements from the stack.
  • l (loop) — start loop: the loop repeats as long as S0is non-zero and there are elements in the stack.
  • m (multiply) — push S0*S1.
  • n (number) — push the number of characters in the current list item (including whitespace).
  • o (output) — print S0 as a number.
  • p (print) — print S0 as a character.
  • q — no operation.
  • r (remainder) — push S0 mod S1.
  • s (subtract) — push S0-S1.
  • t (terminate) — terminate program execution.
  • u (unbring) — pop S0 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 — pop S0.
  • y — remove Sn, where n is the number of characters in the current list item.
  • z (zero) — push 1 if S0=0, and 0 otherwise.

Examples:

Hello, World!:

Example for versions Progopedia Grocery List

This 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