Occurrence.All

Updated on

Occurrence.All (2) is an enumeration that specifies the occurrence of an element in a sequence. It is a member of the Occurrence.Type and specifies that a list of positions of all occurrences of the found values is returned.

Examples

Let’s look at an example using the Occurrence.All enumeration.

The List.PositionOf function supports an optional Occurrence Type. You can enter the Occurrence.All enumeration in the third argument, or write the shorthand value 2.

// Below statements return a list all matching index-positions: { 0, 2 }
= List.PositionOf( { "ape", "duck", "ape", "cow" },  "ape", Occurrence.All)
= List.PositionOf( { "ape", "duck", "ape", "cow" },  "ape", 2 ) 

The Text.PositionOf function also supports the optional occurrence parameter and shows similar behavior.

// Below statements return a list all matching index-positions: { 3, 8, 13, 16 }
= Text.PositionOf( "We all want pasta", "a", Occurrence.All) 
= Text.PositionOf( "We all want pasta", "a", 2 ) 

Other related enumerations are:

Applies to

Here’s a list of functions that work with Occurrence.Type:

Contribute » | Contributors: Rick de Groot