# Motoko and array thought - sugar

**URL:** <https://forum.dfinity.org/t/motoko-and-array-thought-sugar/40424>\
**Category:** Language Support\
**Tags:** Motoko\
**Created:** [January 23, 2025, 4:57pm UTC](https://forum.dfinity.org/t/motoko-and-array-thought-sugar/40424 "2025-01-23T16:57:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ggreif](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ggreif/32/301_2.png) [@ggreif](https://forum.dfinity.org/u/ggreif)\
**Post date:** [January 23, 2025, 9:29pm UTC](https://forum.dfinity.org/t/motoko-and-array-thought-sugar/40424/2 "2025-01-23T21:29:53Z")

</div>

> [@skilesare](#):
>
> ```auto
> let trx2 = data |>
> Array.map<ICRC16Property, ICRC16MapItem>(_, func(x) : ICRC16MapItem {(x.name, x.value)}) |>
> _.vals() |>
> Map.fromIter<Text,ICRC16>(_, Map.thash);
> 
> ```

I’d write this like:

```Motoko
let trx2 = data
   |> Array.map<ICRC16Property, ICRC16MapItem>(_, func x = (x.name, x.value))
   |> _.vals()
   |> Map.fromIter<Text, ICRC16>(_, Map.thash);

```

and you can abbreviate as well:

```Motoko
let {fromIter; thash} = Map;
let trx2 = data
   |> Array.map<ICRC16Property, ICRC16MapItem>(_, func x = (x.name, x.value))
   |> _.vals()
   |> fromIter<Text, ICRC16>(_, thash);

```

---

_[View the full topic](https://forum.dfinity.org/t/motoko-and-array-thought-sugar/40424)._
