Skip to content

OctoSlurp/golfd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Golfd

A tiny and simple code-golf language, written in Clojure.

Syntax

Anything inside single quotes are pushed to a stack. Every character not inside single quotes is an operator. Operators are basically functions for Golfd. They take the entire stack as argument, and modify the stack as much as they want. Here’s how a hello world program is written, and how it works:

The code:

'Hello, world!'p

Explanation:

So, let’s start with the Hello, world! part. As I mentioned before, anything in single quotes is pushed to the stack. The stack is just an array, so the stack now looks like ["Hello, world!"]. The next part here is p. p is the print operator. It takes the last item on the stack, prints it and removes it from the stack. So we get Hello, world! printed after the p operator and stack is now empty ([]).

One thing to note about the language is that each line has its own stack. This means if you want to clear the stack you can just move to a new line.

Operators

Here’s a list of operators, until there is a proper wiki page.

OperatorDescription
+Adds last 2 items in stack
pPrints last item in stack
PPrints all items in stack
Prints all items in stack joined by spaces
.Takes user input
-Subtracts last 2 items in stack
*Multiplies last 2 items in stack
/Divides last 2 items in stack
sSorts all items in stack (calls clojure.core/sort)
SSorts all items in stack after converting them to numbers
iIncrements last item in stack
dDecrements last item in stack
IIncrements all items in stack
DDecrements all items in stack
~Splits the last item in stack by spaces, and adds it to the stack
>Moves item at index to top of the stack, the index is the last item of the stack

About

A simple golfing language written in Clojure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published