# Core DataWeave collection functions

*MuleSoft Developer Study Guide · Transforming Data · Last updated October 28, 2026 · https://www.certifyforce.com/study-guide/mulesoft-developer/transforming-data/core-dataweave-collection-functions*

Predict what map, reduce, groupBy, pluck, mapObject, joinBy, flatten and distinctBy return, including the $, $$ and $$$ placeholders, reduce's default accumulator and the shape (array, object or string) each function produces.

- Certification: Salesforce MuleSoft Developer
- Exam section: Transforming Data
- Study guide: https://www.certifyforce.com/study-guide/mulesoft-developer

**Official exam objective:**

> Predict the result of core DataWeave functions.

## What the exam expects

- Predict the output of `map` and `pluck` when the lambda uses the `$`, `$$` and `$$$` placeholders.
- Trace `reduce` step by step with and without an initial accumulator value, including on an empty array.
- Predict the shape `groupBy` returns (an object of arrays) and tell `pluck` (array) from `mapObject` (object).
- Turn an array into a String with `joinBy` or `reduce`, and predict `flatten` and `distinctBy` on nested or duplicate data.
- Key terms: **lambda** (anonymous function passed to a function such as `(item, index) -> ...`); **placeholder** (`$`, `$$`, `$$$` used when the lambda's parameters are not named); **accumulator** (the running result `reduce` carries between iterations); **criteria** (the value a lambda returns that `groupBy` or `distinctBy` groups or de-duplicates on); **dw::Core** (the module of core functions every script imports automatically).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| Core module | `dw::Core` is imported automatically into every script | [Core (dw::Core)](https://docs.mulesoft.com/dataweave/latest/dw-core) |
| `map` placeholders | `$` = item, `$$` = zero-based index | [map](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-map) |
| `pluck` placeholders | `$` = value, `$$` = key, `$$$` = index; returns an array | [pluck](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-pluck) |
| `mapObject` result | An object; the mapper returns an object | [mapObject](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-mapobject) |
| `reduce` placeholders | `$` = item, `$$` = accumulator | [reduce](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-reduce) |
| `reduce` default accumulator | First element; the lambda starts with the second | [reduce](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-reduce) |
| `reduce` on `[]` | `null` with no initial value; the initial value otherwise | [reduce](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-reduce) |
| `groupBy` result | Object keyed by criteria values; each value an array of whole items | [groupBy](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-groupby) |
| `joinBy` | Array to a single String with the separator between items | [joinBy](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-joinby) |
| `flatten` depth | One level only; empty subarrays omitted | [flatten](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-flatten) |
| `distinctBy` | Lambda result is the uniqueness criteria; original items returned | [distinctBy](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-distinctby) |

## Check yourself

- What do the documented multiply examples return for `[2,3,3]` with no initial value and for `[2,2,3]` with `acc = 3`?
- Why must a `mapObject` mapper return an object rather than a bare value?
- When does `reduce` return null?
- When should you choose `pluck` over `mapObject`?
- When would a script need a second `flatten`?

## Sources

- [Core (dw::Core)](https://docs.mulesoft.com/dataweave/latest/dw-core)
- [map](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-map)
- [reduce](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-reduce)
- [groupBy](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-groupby)
- [pluck](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-pluck)
- [mapObject](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-mapobject)
- [joinBy](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-joinby)
- [flatten](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-flatten)
- [distinctBy](https://docs.mulesoft.com/dataweave/latest/dw-core-functions-distinctby)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 7 linked practice questions, and unlimited timed mock exams are included with the MuleSoft Developer pack (USD $19): https://www.certifyforce.com/practice-exams
