set_has_element
This page explains how to use the set_has_element function in APL.
set_has_element returns true when a dynamic array contains a specific element and false when it doesn’t. Use it to perform fast membership checks on values that you have already aggregated into a set with functions such as make_set.
Usage
Syntax
set_has_element(set, value)Parameters
| Name | Type | Description |
|---|---|---|
set | dynamic | The array to search. |
value | scalar | The element to look for. Accepts long, real, datetime, timespan, string, bool. |
Returns
A bool that’s true when value exists in set and false otherwise.
Example
Use set_has_element to determine if a set contains a specific value.
Query
['sample-http-logs']
| extend hasElement = set_has_element(dynamic([1, 2, 3]), 2)Output
| _time | hasElement |
|---|---|
| May 22, 11:42:52 | true |
List of related functions
- set_difference: Returns elements in the first array that aren’t in the second. Use it to find exclusions.
- set_union: Returns the union of two or more sets. Use it when you need any element that appears in at least one set instead of every set.