Search
ctrl/
Ask AI
Light
Dark
System

Sets

Subtopics

Functions in EdgeDB can operate on whole sets or on individual elements. This boils down to how the function parameters are defined, whether they are using the set of modifier (indicating that the parameter will take a set as a whole) or not, although for built-in functions this is usually intuitive.

Let's try out the simple element-wise function len, which works on anything that can be indexed (i.e., strings, arrays, and bytes literals):

Input
Run
Output Objects
Press the 'Run' button to evaluate the input

When a function which treats its parameters in element-wise fashion is applied to a set, a new set is constructed by applying the function to each original element separately. Try different sets as inputs to len:

Input
Run
Output Objects
Press the 'Run' button to evaluate the input

If there are more than one element-wise function parameters, then the function is applied to the Cartesian product of the input sets. Try out different combinations using str_repeat:

Input
Run
Output Objects
Press the 'Run' button to evaluate the input