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. 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!
What are the basic logical operators?
Keywords: not, negation, conjunction, and, disjunction, or, XOR, NAND, Sheffer stroke, NOR, converse.
How do I do arithmetic?
Keywords: addition, subtraction, multiplication, division, modulus, exponentiation.
Note that mathematical order of operations are preserved in Avail (PEDMAS).
What are the comparison operators?
Keywords: greater than, less than, equal, greater than or equal, less than or equal, not equal
Character comparison is based upon a character's numeric code point
What other math operations are available?
Keywords: factorial, GCF, LCD, natural log, logarithm, maximum, minimum, summation, n-ary product
How do I do bitwise operations?
Keywords: NOT, AND, OR, XOR, shift
How do I build conditionals?
How do I build chained conditionals?
Synonyms: tuples, arrays, maps, sets, containers, lists, dictionary, groups, bag, queue, stack.
Each of the displayed methods are generally applicable for tuples, maps, sets given some potential syntactical differences.
How do I check to see if a collection is empty?
How do I test the elements of a collection?
How do I count the number elements of a collection that meet a specific criteria?
How do I filter the elements of a collection?
Or, "How do I find every element of a tuple/set/map that satisfies a predicate function?"
Or, "How about rejecting each element of a tuple/set/map that satisfies a predicate function?"
This does the same computation, but in parallel.
Or, "How do I group or classify the elements of a tuple/set by the result of a function returning a classification?"
Here's an old-school subscripting loop.
How do I create various while loops?
How can I loop through each element of a tuple/set/map/reader/stream?
Keywords: enhanced for loop
There are lots of ways to accomplish this, each of which is the same general syntax for each data structure. Here are just a few.
Here's how to loop through the tuple in parallel. Note that the result is unstable.
Here's how to do the same parallel loop for a set.
...And a map
How do I transform each element of a tuple?
Or, "How do I map a tuple through a function?"
These do the same computation, but in parallel.
Strings are tuples of Characters. Strings respond to all tuple methods. Each element of a string (character) respond to character methods.
How do I represent a character?
How do I get a character's code point? character representation from a code point?
How do I inspect characteristics of a character?
How do I convert characters?
How do I convert non-string values to strings?
Keywords: stringification, stringify, textual representation.
How do I print strings to the standard output stream?
Keywords: printing, standard out, I/O.
Printing returns no value, so it has to be executed in a "Run_" block on the Availuator.
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!
Exceptions are forms of objects in Avail.
How do I raise an exception?
Note that the result of running the following code snippets in the Availuator will result in the reporting an error.
How do I handle exceptions?
Keywords: exception handling, error handling, unwind
 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.
|Return to Documentation|