minigolf is a tiny stack-based language inspired by Vyxal's corpus. Programs can be quite long compared to modern golfing languages due to its extremely limited set of builtins, but they tend to be shorter compared to practical languages. Besides constants and characters that transpile to minigolf, it currently has 8 commands (actually 12 due to operator overloading):
||(int / float)||map |
||(int/list, int)||Multiply. (Vectorizes)|
|(list)||Flatten the list on TOS.|
||(int/list, int)||Add. (Vectorizes)|
|(list)||Sum the TOS. (Vectorizes at depth 1)|
||Push next (cyclic) input (or |
||Push current item in map (or |
||(any, any)||Swap the top two stack items.|
||(list/int, int)||Equality. (Vectorizes)|
|(list, list)||Zip two lists together.|
Additionally, the following characters transpile to their equivalent minigolf substring:
The input for the program is taken from STDIN, split by newlines, and each item is evaluated as Python. Strings are converted to lists of codepints. This produces an input list for the program.
The entire stack is implicitly outputted after the program. If the
-c flag is on, then each stack item is implicitly
chr'd. If TOS is an array, then the inner lists are flattened, then the inner lists mapped with
chr then joined with
"", then the outer lists joined with
"\n", and finally the resulting list is outputted.
It is important to note that unlike other stack-based langauges such as 05AB1E or Factor, the map builtin does not implicitly push the current iterated item onto the stack. An explicit
n is required to do that. (This makes the map builtin a bit more flexible.)
The map loop pops TOS after each iteration, and pushes a list of each popped item after the loop.
Additional constants and flags in minigolf can be found by reading the source code.
Sort the input list
Here is a program I wrote on CGCC that sorts the input list via insertion sort.
Factorial of the input