#O ##Factoid O is a programming language inspired by GolfScript, Pyth, K, and tons of other languages. It was made by Phase (me) over the summer of 2015, so it is relatively new. The interpreter was originally written in Java, but development has recently switched to a C interpreter. Here are some examples of the language.
#Length 4
M]+o
This program gets the sum of all the digits of the input number. (1234
= 1 + 2 + 3 + 4
= 10
)
M
is a builtin macro that calls[i~
.[
Starts an array (which really acts like another stack)i
Gets an input from stdin and pushes it to the stack (the array in this case)~
Evaluates the top of the stack (the input) as O code, which pushes each digit of the input number to the stack.
]
Closes the array, pushes it to the stack+
Folds the array by adding all the elements togethero
Outputs the sum of the digits to stdout.
It's a pretty complicated program for only being 4 bytes!
##Length 3
{1}
O supports CodeBlocks like GolfScript and CJam. This is a CodeBlock that pushes the number 1 to the stack when it is run. Just creating a CodeBlock pushes the block itself to the stack, without running it. We could assign it to a variable, or use ~
to run it.
##Length 2
Ao
A
pushes 10 to the stack. o
pops the top of the stack and outputs it to STDOUT. This program outputs 10 to the screen.
##Length 1
1
Any number literal will be pushed to the stack as an integer. The stack is not outputted when the code ends (though this may change soon!), so the program exits without outputting anything.