Required List Element
The Required List Element pattern enables us to verify elements without knowing their position.
This example works for basic types like ints and strings.
This example works for a list of structs.
If you want to check that structs have a specific pattern, you can replace the _
with a definition.
Even better would be to apply the definition to the original list.
Some considerations:
- You will need the elements to have a unique key.
You could use
true
or any (_
) as the value if you don’t care about duplicate keys with different values. - This pattern will change once Associative Lists are implemented.