
Last chance! 50% off unlimited learning
Sale ends in
many
matches 0 or more of pattern p
. In BNF notation,
repetition occurs often enough to merit its own abbreviation. When zero or
more repetitions of a phrase p
are admissible, we simply write
p*
. The many
combinator corresponds directly to this operator,
and is defined in much the same way.many
differs from (Hutton92) due to the nature
of R's data structures. Since R does not support the concept of a list of
tuples, we must revert to using a list rather than a vector, since all values
in an R vector must be the same datatype.
many(p)
maybe
, some
Digit <- function(...) {satisfy(function(x) {return(!!length(grep("[0-9]", x)))})}
many(Digit()) ("123abc")
many(Digit()) ("abc")
Run the code above in your browser using DataLab