What you will do
You will run the prepared expression in the playground above, change one input at a time, and explain the result. Start in CEL only, then repeat the same rule in CEL + JSON.
How it works
map() evaluates a transformation for every item and returns the transformed results in the same order. It always returns a list. Unlike filter(), it does not decide which items survive; it decides what each output item becomes.
Read the prepared example
The CEL + JSON rule is:
prices.map(price, price * 2.0)Its input is:
{
"prices": [2.5, 4, 6.5]
}The CEL only tab contains the values and the rule in one expression. The enabled cel.bind() extension keeps each name local to its final argument.
Evaluation step by step
- The first price becomes
2.5 * 2.0 = 5.0. - The same transformation runs for the remaining prices.
- The result is
[5.0, 8.0, 13.0].
Your task
- Run the example.
- Change the multiplier to
1.2. - Replace the transform with
price >= 4.0and inspect the list of booleans.
Expected observation: A transform may return any supported type; the final experiment returns one boolean per input price.
Common mistake
Do not expect map() with a boolean expression to remove false items. It returns those boolean values.
Show the explanation
Yes. Each output position corresponds to the same input position.
Knowledge check
Does map() preserve input order?
Key takeaway
Use map() to transform every item and filter() to select items.
Sources
CEL-DEV— official CEL overview.CEL-LANG— official CEL language definition.CEL-GO-BIND— official documentation for the optionalcel.bind()extension used by the self-contained tab.