README

Examples

These scripts showcase various parts of the language.

euclid-gcd.alma

Implements Euclid's algorithm.

Showcases recursion and the swap macro.

factorial.alma

Declares a postfix:<!> operator for the factorial.

Showcases custom operators.

ff.alma

Implements the infix:<ff> macro and family.

Showcases stateful macros, and operator macros with their own tighter precedence level. Also showcases thunky macro arguments.

format.alma

Implements a format macro for formatting text.

This macro does some checking at compile-time, catching possible logical errors early.

in.alma

Implements an infix:<in> operator for checking membership/elementhood.

Showcases custom (non-macro) operators with equiv precedence.

incdec.alma

Implements the various prefix/postfix -- and ++ operators.

Showcases mutating operators. Currently not-quite-correctly, due to known problems with the Single Evaluation Rule.

name.alma

Implements a name macro which extracts the name of a variable or property.

Showcases a thing that macros can do that regular functions can't. The names of variables are a property of the source text/AST, but usually not a part of the running code. By virtue of running at compile time, a macro can extract the name and re-insert it as a string literal in the code.

nicomachus.alma

Implements a number guessing game.

nim-addition.alma

Implements a infix:<āŠ•> operator for "bitwise xor".

Showcases custom operators with equiv precedence. Also inadvertently showcases how Alma is somewhat suffering from the lack of support for low-level bitwise operators; see #461.

power.alma

Implements an infix:<**> power/exponentiation operator.

Showcases a custom right-associative operator.

quicksort.alma

Implements QuickSort (though not the in-place version).

quine.alma

A quine, that is, a program that outputs its own source code.

swap.alma

An implementation of the swap macro.

Also currently suffers from effects from the Single Evaluation Rule.

x-and-xx.alma

Implements infix:<x> and infix:<xx>, for duplicating strings and arrays, respectively.

Showcases a macro with a thunky argument.

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.