Returns True if item is in list . The list may contain objects of any type, it does not have to be homogenous.
member ( item As Any, _
list As List, _
Optional key As Name = :Identity, _
Optional test As Name = :Equal ) As Boolean
Argument | Type | Description |
---|---|---|
item | Any | The item to check for list membership. This argument is permitted to be NoValue . |
list | List | A list of items. |
key | Name | Optional; the name of function to be called with each item in the list ; default is :Identity. |
test | Name | Optional; the name of test function to be applied to key results of items in the lists ; default is :Equal. |
Intent >member(3, {7, 4, 3, 9, 0})
--> True
Intent >member(3, {7, 4, 9, 0})
--> False
Intent >member(3, {7, 4, 9, 0}, test := :sameType?)
--> True
Function sameType?(I As Any, j As Any) As Boolean
sameType? = (typeName(i) = typeName(j))
End Function
Intent >member(3, {a, b, c, d}, test := :sameType?)
--> False
Again, this example uses the custom function shown in the preceding example. Intent >member(2, {"a", "bcd", "ef", "ghi"}, key := :length)
--> True
Returned
True
because one of the members of the
list
, "ef", has a length of 2.