Suppose Event is record with fields like eventName and eventParameter. I want to assert for the condition if some eventName say "EV1" is present in list of records. For list of native Data types (let say Parties) I can simply check with (elem in following)
as given in docs. Can anyone help me what would be the syntax for record data type?
How do I check if an element is present in list of records in DAML?
299 views Asked by Prachi Gupta At
1
elem
is an instance of a more general functionany : (a -> Bool) -> [a] -> Bool
which takes a predicate and a list of elements and returns true if the predicate holds for at least one element in the list.elem x xs
is equivalent toany (\y -> x == y) xs
.Using
any
you can express your example as follows: