In addition, both match and matchall can be annotated with the while modifier. It this case the semantics of the matching construct is to repeat until no more rule is applicable. For example, the following code fragment returns the last element of a list
datatype List = #[] | #[ int ... List ]; int last (List l) { match while (l) { case #[]: assert(0); // an error case #[i]: return i; case #[h ... t]: l = t; } }