Description
Counts the frequency of each element in a list, returning a map where keys are the unique elements and values are their occurrence counts.Syntax
Parameters
Returns
Type: map (object) A map where each key is a unique element from the list and each value is the count of how many times that element appears. Returns an empty map if input is not an array.Examples
Example 1: Basic Frequency Count
Example 2: Tag Analysis
Example 3: Finding Most Common Values
Example 4: Word Frequency Analysis
Notes
- Returns empty map if input is not an array or is
null nullandundefinedvalues are stored with key"null"- All elements are converted to string keys in the result map
- Useful for analytics, statistics, and data exploration
- Can be combined with
keys()and sorting for top-N analysis
See Also
- coll.union - Get unique elements (keys would give unique items)
- coll.intersection - Find common elements
Frequently Asked Questions
What does flex.coll.frequencies return?
What does flex.coll.frequencies return?
It returns a map where each key is a unique element from the input list and each value is the number of times that element appears.
Can I use frequencies with non-string elements?
Can I use frequencies with non-string elements?
Yes. The function works with any comparable data types including strings, numbers, and booleans.