Expression Cookbook

Here can be found handy expressions that illustrate a wide variety of small programming tasks.

Each recipe begins with a question that you might ask, like "How do I create a literal array?" Very likely, you are coming from some other programming language, and framing your question in its terms. We have taken care to include alien terminology in the introduction of each section. This means that a search of the page from your browser will be likely to turn up the right information. This is also a good way to learn Avail's native terminology.

Following each question is a list of answers, each of which is provided as a sample expression. Most of these expressions are prefixed with an exclamation point!(U+0021). You can use the Availuator to run any of these expressions from the workbench. Simply copy the entire expression, including the leading exclamation point, paste it into the workbench's input field, and press Enter.[1] If you want to use one of these expressions in a module, then do not include the leading exclamation point in the copy. This character is part of the send of "`!_", the Availuator's primary expression evaluator.

After the sample expressions are hyperlinks into the Stacks. Each hyperlink targets a method used in a sample expression. Only methods of primary relevance to the topic are targeted.

Note that the results of the expressions are deliberately not included on this page. Consider this strong encouragement to play with the recipes in the Availuator! :-)

How do I print strings to the standard output stream?

How do I trim leading and trailing whitespace?

How do I format strings?

Keywords: formatting, formatter, printf.

The input in the Availuator is a text field. Because of this, it doesn't recognize newlines. In order to break continuous
strings over multiple lines, ignoring newlines and other whitespace, in an actual avail module, you'd insert a back slash (\)
at the end of the line immediately preceding the newline character. On the next line, all white space is ignored up to the
first occurrence of the combination of a back slash (\) immediately followed by a pipe (|). The following example is meant
for use in an Avail module and will not run in the Availuator.

The following example has been created to work specifically in the Availuator. This will work as is in an Avail module,
however, all the newlines will be captured as they are literally placed in the current code. To run this example in an
Avail module utilizing continuous string breaking formatting, the above line breaking methodology would need
to be implemented at each newline. Indentation at the next line would also be added before the "\|" characters.
We considered not adding the following example because of this, but I had too much fun building it not to show it!

How do I handle exceptions?

[1] Be sure that you have already loaded the Availuator by double-clicking it in one of the tree views on the left side of the workbench. Otherwise the workbench won't be able to find the "`!_" entry point.