mep

From Esolang
Jump to navigation Jump to search

mep is a programming language made by Braden, or rather one of his penguins, Pongo. Pongo wrote this article, and he named it after a catchphrase of his. He made it as a programming language he could write in, after finding that BF and Befunge were too hard.

Commands

There are three types of commands, depending on what punctuation the line ends with.

  • A period means to alter the stack and its contents.
  • A question mark is a conditional jump.
  • An exclamation mark is input and output.

Stack commands

There are nine stack commands, which are indicated by the line ending with the period. They are determined by two meps at the start of the line, and what punctuation follows each of them.

mep. mep.

This pushes a number onto the stack. Between the second mep and the last one, you put n meps, where n is the amount of trits in the number. The end punctuation is interpreted as ternary, in big endian. "." is 0, "?" is one, and "!" is two. So

mep. mep. mep? mep? mep! mep. mep.

is 42.

mep. mep?

Pops two numbers, A, then B, and pushes A+B onto the stack.

mep. mep!

Like "mep. mep?" but subracts, and pushes the result onto the stack.

mep? mep.

Like the previous two commands but multiplies.

mep? mep?

Pops two numbers, A, then B, and pushes the remainder, then the quotient, so the quotient is on top. This function only returns integers. Dividing by zero will give you a Grorning Utty (no need to explain, Braden likes to use the term a lot).

mep? mep!

Pops and discards the top element.

mep! mep.

Duplicates the number on top of the stack.

mep! mep?

Pops a number N off the stack, and rolls the top N elements left. If N is zero, pushes the length of the stack onto the stack. If N is negative, then pop another number O, and roll the numbers starting at the absolute value of N (where 0 is the top) and the O elements after.

mep! mep!

Like "mep! mep?" but rolls to the right.

Jumps

Jumps are indicated by the second mep on the line being punctuated with a question mark.

The command pops three numbers, A, B, and C off the stack. The punctuation of the first mep indicates a comparison.

A period is equality. A question mark is a less than. An exclamation mark is a greater than.

If A x B, where x is the comparison operator, then go to line C. If C is zero, halt. If C is a non existent line, that's the other way to get a Grorning Utty.

I/O

I/O is indicated by the line ending in an exclamation mark. An I/O instruction has three meps. This is unique in that it has commas, which come after each of the first two meps (or also periods).

For the first mep, if there is a comma, then pop and output a value, otherwise if there is a period, input a value which is stored as a number. For the second one, a comma means ASCII, otherwise integers.

Examples

Hello world:

mep. mep. mep? mep? mep. mep. mep! mep.
mep, mep, mep!
mep. mep. mep? mep! mep? mep. mep? mep.
mep, mep, mep!
mep. mep. mep? mep! mep! mep. mep?
mep! mep. mep.
mep, mep, mep!
mep, mep, mep!
mep. mep. mep? mep! mep! mep? mep? mep.
mep, mep, mep!
mep. mep. mep! mep. mep. mep. mep.
mep, mep, mep!
mep. mep. mep? mep. mep? mep! mep.
mep, mep, mep!
mep. mep. mep! mep. mep. mep? mep! mep.
mep, mep, mep!
mep. mep. mep? mep! mep! mep? mep? mep.
mep, mep, mep!
mep. mep. mep! mep. mep. mep. mep. mep.
mep, mep, mep!
mep. mep. mep? mep! mep! mep. mep? mep.
mep, mep, mep!
mep. mep. mep? mep! mep? mep. mep. mep.
mep, mep, mep!
mep. mep. mep? mep? mep? mep! mep.
mep, mep, mep!
mep. mep. mep. mep.
mep! mep. mep.
mep! mep. mep.
mep. mep?

Turing Complete?

mep has every command needed to be Turing-complete, but we need an example.