HELP REV                                         Steven Hardy, January 1978

This procedure reverses the list given to it as argument. For example:

    rev([a b c d]) =>
    ** [d c b a]
    rev([jack loves john]) =>
    ** [john loves jack}
    rev([cities of england are [london leeds sheffield]]) =>
    ** [[london leeds sheffield] are england of cities]

Notice that REV does not reverse sub-lists.

Here are some useful defintions using REV:

    define last(list);
        hd(rev(list))
    enddefine;
    define butlast(list);
        rev(tl(rev(list)))
    enddefine;
    last([a b c d]) =>
    ** d
    butlast([a b c d]) =>
    ** [a b c]

REV could be defined as:

    define rev(list);
        if list = [] then
            []
        else
            rev(tl(list)) <> [% hd(list) %]
        endif
    enddefine;

See also HELP * NCREV
