


Mythryl makes it easy to write anonymous functions. The basic syntax is:
fn arg = expression
Such functions are typically passed as arguments to other functions:
linux$ my
eval: map (fn string = implode (reverse (explode string))) [ "abc", "def", "ghi" ];
["cba", "fed", "ihg"]
Like named functions, Mythryl anonymous functions support implicit case statements. The general syntax is
fn pattern => expression;
pattern => expression;
pattern => expression;
...
end
Arbitrary pattern-matching may be done, but ordinarily if you are going to write many cases with complex patterns and expressions, you will probably just make it a named function.
Here is a simple example of using this facility to special-case empty strings:
linux$ my
eval: map fn "" => "<empty>"; string => implode (reverse (explode string)); end [ "abc", "def", "ghi", "" ];
["cba", "fed", "ihg", "<empty>"]


