\   Example that demonstrates a way to implement a form of mutual recursion
\   in terms of simple recursion.
\
\   Based on an example from Alan Kay's "Early History of Smalltalk".

main

Where

Let (main _)
    (LIST.for_each
        (odds_evens ["one" "two" "three" "four" "five"])
        STDIO.print_line)

Where

Let (odds_evens items)
    For (LIST.append (select `odds items) (select `evens items))
        Define (select mode items)
            Match items
            | `nil `nil
            | `cons.{item items}
                Match mode
                | `odds (item :: (select `evens items))
                | `evens (select `odds items)
                ;
            ;

Where

Let LIST Package "list"
Let STDIO Package "stdio"