Wherever a pattern occurs (
lc, etc.) it
can be followed by an optional guard which has the form
(when test ...).
Guard tests are the same as in vanilla Erlang and can contain the
following guard expressions:
(cons gexpr gexpr)
(list gexpr ...)
(tuple gexpr ...)
(progn gtest ...)- Sequence of guard tests
(if gexpr gexpr gexpr)
(guard-bif ...)- Guard BIFs, arithmetic, boolean and comparison operators
An empty guard,
(when), always succeeds as there is no test which
fails. This simplifies writing macros which handle guards.