Skip to content
An esoteric programming language
Branch: master
Clone or download
Latest commit 1f06644 Jan 6, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples 60: Added shebang and changed file permissions Dec 14, 2015
.gitignore 60: Added shebang and changed file permissions Dec 14, 2015
README.md
base.py 60: Added shebang and changed file permissions Dec 14, 2015
debug.py 60: Added shebang and changed file permissions Dec 14, 2015
errors.py 60: Added shebang and changed file permissions Dec 14, 2015
mw 61: Removed extension, renamed, and updated readme Dec 14, 2015
shorthand.py 60: Added shebang and changed file permissions Dec 14, 2015
standard.py 66: Fixed split error Jan 6, 2016
synclist.py

README.md

Milky Way

Milky Way is a stack-based programming language.

Usage

./mw test.mwg

All program files must end with .mwg to be valid.

Input

Input is taken through the command line with the -i option.

./mw test.mwg -i "test"

Commands

Opcode Description
; Swap the top two stack elements
< Rotate the stack leftward
Rotate the top N stack elements leftward where N is the TOS
> Rotate the stack rightward
Rotate the top N stack elements rightward where N is the TOS
^ Pop the TOS without outputting it
| Pop the Nth stack item without outputting it where N is the TOS
: Duplicate the TOS
+ Push the sum the top two stack elements to the stack
- Push the difference of the top two stack elements to the stack
* Push the product of the top two stack elements to the stack
/ Push the quotient of the top two stack elements to the stack
a Perform logical not on the TOS
b Perform logical equals on the top two stack elements
c Perform logical and on the top two stack elements
d Perform logical or on the top two stack elements
e Perform logical greater than on the top two stack elements
f Perform logical less than on the top two stack elements
g Push the Nth root of the top stack element (default to 2) to the stack
h Push the TOS to the power of second stack element to the stack
i Push the primality of the TOS to the stack
j Push the absolute value of the TOS to the stack
k Push the negative absolute value of the TOS to the stack
l Push 10 to the Nth power to the stack
m Push A/B and A%B to the stack where A and B are the top two stack elements
n Push A%B to the stack where A and B are the top two stack elements
o Push the sine of the TOS to the stack
p Push the cosine of the TOS to the stack
q Push the tangent of the TOS to the stack
r Push the inverse sine of the TOS to the stack
s Push the inverse cosine of the TOS to the stack
t Push the inverse tangent of the TOS to the stack
u Push the rounded TOS to the stack
v Push the floor of the TOS to the stack
w Push the ceiling of the TOS to the stack
x Push A rounded to the nearest multiple of B to the stack
y Push the length of the TOS to the stack
z Reserved to raise an exception due to it being an undefined opcode
\ Split A at B where A and B are the top two stack elements
= Dump the TOS to the stack
@ Terminate the program
¡ Output the TOS and terminate the program
Ω Push a list of the top N stack elements
ß Push a tuple of the top N stack elements
A Push the integer representation of the TOS to the stack
B Push the string representation of the TOS to the stack
C Push the list representation of the TOS to the stack
D Push the tuple representation of the TOS to the stack
E Push the first N primes to the stack as a list
F Push the sum of elements A+B, B+C, C+D, etc. from the TOS
G Push the sum of the TOS
H Push the reversed TOS
I Empty the stack
J Push the stack to a list
K Push a range of the TOS as a list (exclusive)
L Push a range of the TOS as a list (inclusive)
M Push the time as a string
N Push all the permutations of the TOS
O Pause the program for N seconds
P Push the length of the TOS in bytes
R Push 1 to the stack
S Push 2 to the stack
T Push 3 to the stack
U Push 4 to the stack
V Push 5 to the stack
W Push 10 to the stack
X Push 20 to the stack
Y Push 50 to the stack
Z Push 100 to the stack

If-Else Statements

An if statement is signified by the ? operator followed by a set of braces.

?{}

The conditional and code blocks are separated by _.

?{1_1_0}

The above statement is equivalent to the following Python code, where the literals in each block are analogous with pushing to the stack.

if 1:
	1
else:
	0

if statements can have empty blocks, as shown below. The following code does nothing.

?{1__}

They can also have empty conditionals. In this case, the truth of the TOS is evaluated as the conditional.

?{_1_0}

For Loops

A for loop is signified by the % operator followed by a set of braces.

%{}

The code above does nothing.

%{5£!}

The code above will output each integer in range(5) in increasing order.

While Loops

A while loop is signified by the & operator followed by a set of braces.

&{}

The code above is an infinite loop that does nothing. However, while loops can be functional.

5&{~1-!}

The code above will loop until the TOS becomes false. A while loop like this must begin with the ~.

5&{~1-!~5+}

The code above is another type of while loop which builds on the previously described loop. This loop must begin with the ~. It will execute everything between the tildes in the loop, but once the TOS becomes false, the code on the right side of the second tilde will be executed.

Mapping

By using a mapping, you can apply a code block to every element of a list.

§{}

The code above is an empty mapping.

5L§{!}

The code above will output the numbers 0 through 5.

You can’t perform that action at this time.