| Did you know ... | Search Documentation: |
| Pack canny_tudor -- prolog/dcg/sequence.pl |
This DCG rule is useful for parsing or generating sequences of elements where the separator is not fixed. It solves a problem with the standard sequence//3 predicate, which cuts when it encounters any separator, including a final separator that does not have a subsequent element. This variation looks for a separator with a subsequent element but ignores a separator without a subsequent element that may be present at the end of the sequence, allowing for more flexible parsing and generation of sequences.
Fails for trailing separators without a subsequent element. A separator requires something to follow it, and if nothing follows, the sequence fails. This behaviour is useful for parsing sequences where a trailing separator is not allowed.
Also fails for empty lists. An empty list has no elements to match, and the sequence consequently fails.