# Tips for golfing in Add++

Add++ is the Language of the Month for January 2022, and so I'm asking for tips for golfing in it. Please stick to tips specific to Add++, and avoid general tips such as "remove whitespace" or "avoid comments".

## Use L for the main function, D for helper functions

Unnamed* lambdas have the syntax

L<flags>,<code>


For example. This is much shorter than the named version

D,<name>,<flags>,<code>


For a single byte function name, using a lambda is 3 bytes shorter, and this increases as the name grows longer.

*: Lambdas are stored in the interpreter as functions with the names lambda 1, lambda 2, etc. so can be accessed this way

If you're submitting a function submission, the main function should always be an unnamed lambda, and any helper functions should be named. Consider,

L,€{lambda 2}
L,'


vs

L,€g
D,g,@,'


which saves 5 bytes

## Call your helper functions I, K, Y, Z, g, k, l, u or w

Add++ doesn't have any way to combine multiple functional builtins into one command (for those familiar, like Jelly's \$¥ quicks). If you want to e.g. filter on a complex condition, you'll need to define a helper function containing the code for that condition.

When calling other functions from functional mode, you surround the name with {...}:

D,main,@,€{triple}
D,triple,@,3*


However, if the braces are omitted, it will only take the next character immediately after the quick. In this case, if there's a name clash between a builtin and a user-defined function, the interpreter defaults to the builtin.

So, for this example,

D,main,@,€f
D,f,@,5+


The € will actually call the f builtin (prime factors), not the function f (add 5).

If the builtin isn't defined however, such as g, it will use the function instead. Therefore, you can save 2 bytes per helper function call like

D,main,@,€g
D,g,@,5+


The undefined builtins are I, K, Y, Z, g, k, l, u and w, so name your helper functions these first, then move onto having to use braces if you have more than 9 helpers

Always use D Loop when you use W if you want to execute once and go to start of the loop if the condition is 1. This will prevent from duplicating the code.

# Use & to swap variables.

This

A:1
B:2
; Start of the Swap
C:A
A:B
B:C
; End of the Swap


Can be shortened to

A:1
B:2
; Start of the Swap
A&B
; End of the Swap


(This can be useful if you try to swap in loops)