Skip to content

Instantly share code, notes, and snippets.

@schas002
Last active April 10, 2016 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schas002/1a8bda6f34f7eca8a47faa103d6f3937 to your computer and use it in GitHub Desktop.
Save schas002/1a8bda6f34f7eca8a47faa103d6f3937 to your computer and use it in GitHub Desktop.
Unipants' Golfing Language.

Unipants' Golfing Language

Unipants' Golfing Language (TODO: choose a better name) is a language inspired by Shifty Eyes.

Instructions

I/O

  • i - input an integer into the stack

  • I - input a character into the stack

  • o - pop the top of stack and output an integer

  • O - pop the top of stack and output a character

Characters are actually integers, just that they are kept as their ASCII ordinals. So the letter A is actually kept in stack as 65, the ASCII ordinal for A.

Push/Pop

  • c - push a 0 into the stack

  • _ - DROP the top of stack

Increment/Decrement

  • u - increment the top of stack

  • d - decrement the top of stack

Arithmetic

  • + - add the top of stack and second-to-top of stack

  • - - subtract from the top of stack the second-to-top of stack

  • * - multiply the top of stack and second-to-top of stack

  • / - divmod - divide the top of stack by second-to-top of stack, push the quotient and remainder (quotient to top of stack)

Stack Primitives

  • $ - DUP - push a copy of the top of stack (1 2 ==> 1 2 2)

  • % - SWAP - swap the top of stack and second-to-top of stack (1 2 3 ==> 1 3 2)

  • @ - ROLL - roll the stack upward (1 2 3 4 ==> 4 1 2 3)

  • ^ - PICK - push a copy of the second-to-top of stack (1 2 ==> 1 2 1)

Nested Structures

  • ? - if: the nested structure runs if and only if the top of stack is nonzero

  • l - while: the nested structure runs while the top of stack is nonzero

  • : ends both nested structures.

Example

Counts down from n to 1.

il$od:
i      - input
 l   : - while loop
  $    - dup
   o   - output
    d  - decrement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment