# Tips for golfing in Jolf

Jolf is a procedural golfing language made by @CᴏɴᴏʀO'Bʀɪᴇɴ.

What tips do you have for golfing in Jolf?

These tips should be at least somewhat specific to Jolf, e.g. remove comments is an answer, but not a very good one.

Jolf has many ways to "auto assign" variables. The standard one is γ, which takes the value of the next expression. Β is the same thing, but converts the next expression to a number.

Also, ζ (zeta) is a variable initialized to -1/12 (guess why), and can be re-assigned with Ζ (Zeta).

For example, let's say you want to compare I (the input string) to an operation over itself. For now, let's see if I + I = reverse(I + I). This is written as, conventionally:

=+II_+II


But this can be golfed down to:

=γ+II_γ

• Does your -1/12 zeta have to do with string theory? I know of a way to add up every natural number and obtain -1/12 Apr 25, 2016 at 18:45
• @GheyPhistor Which string theory? But yeah, it's that the zeta function over the natural numbers is -1/12. Apr 25, 2016 at 18:48

# Use @

@ is a command that takes the next character in the source code and returns that character's code point. (For example, @X returns 88.) This is often very useful since you can express any number between 0 and 255 in two bytes.

• "between 100 and 255" Apr 25, 2016 at 14:49
• @KennyLau In Jolf, 10 is actually the number 1 and the number 0 not the number 10, so it's more like 10-255. Apr 25, 2016 at 14:52

# JavaScript fall back

If for some strange reason Jolf isn't golfy enough, or simply cannot cope, it may be of use to use JavaScript eval. This can happen in one of two ways.

## 1. Designed eval

Anything inside of $...$ is literally carried over to the JS transpilation. For example, +3$~$5 transpiles to add(3, ~5). Equivalently, +3:~5.

## 2. Array eval

You can use JS arrays in Jolf! Mostly. It's kind of a bug, but I'm not going to fix it. For example:

u[3*5,5/6,(3+4)/5]


Transpiles to:

sum([2 * 3, 5 / 3, (3 + 4) / 5]);

• If for some strange reason Jolf is golfy enough (...?) Jan 6, 2018 at 17:03
• @EriktheOutgolfer isn't ** Jan 6, 2018 at 18:30

As of right now, there are a lot of undocumented things -- the mysterious m module among them, which has a lot of builtins. However, they do exist in the source, and it's really not hard to read once you get the hang of it, so read the source.

• The mysterious math module. Apr 25, 2016 at 14:42
• module. (6 more to go...) Apr 25, 2016 at 14:48

# Increase Function Arity

Every function has an arity. For example, + has an arity of 2. If you want to (say) add 5 elements, you could use 5 +s... or do +θ12345. Specifically:

• θ incrases the arity of the function by 3.
• ~θ increases the arity of the parent function by 3. (So *+~θ345678 increases the arity of the * by 3)
• M increases the arity of the function by 2.
• ~M increases the arity of the parent function by 2.
• ; increases the arity of the function by 1.
• ~; increases the arity of the parent function by 1.
• η decreases the arity of the function by 1.
• ~η decreases the arity of the parent function by 1.
• \xad sets the arity of the parent function to the next character's charcode.
• What's the advantage of *+~θ over *θ+? Apr 26, 2016 at 22:52
• @immibis There isn't in that case, it was merely illustrative. There are some functions in Jolf that pass two functions when parsed. Then, the only way to access the top function's arity is using ~<char>. Apr 26, 2016 at 22:58

# Take advantage of implicit input

If a function does not have enough arguments, it will look to the input for the remainder of the arguments. For example:

+uz


Would transpile to:

add(sum(unaryRange(x)), x)


It's equivalent to

+uzxx


# Use o to store values

Similar to how other languages can assign variables for easy/short referencing, Jolf has o.

For example, oThx prints the input plus 1.

This is a useless example, but when the expression is more complicated than hx, it can save some serious byteage.

Also, v"var name"<val> allows for a multi-char variable name, and V"var name" gets a variable from the scope.

Thanks to Conor for explaining this to me, and giving the previous sentence.

• Also note that v"var name"<val> allows for a multi-char variable name, and V"var name" gets a variable from the scope. Apr 25, 2016 at 14:57
• @CᴏɴᴏʀO'Bʀɪᴇɴ oh, so that's what they do. Adding to the post. Apr 25, 2016 at 14:58
• o Thx for this tip :P Apr 26, 2016 at 2:54
• @EᴀsᴛᴇʀʟʏIʀᴋ It was a pun on o being the assignment variable May 8, 2016 at 23:31
• @CᴏɴᴏʀO'Bʀɪᴇɴ o, yeah.... May 9, 2016 at 1:11