---
# System prepended metadata

title: Motoko Snippets

---

# Motoko Snippets

## Reverse an array

```
import Array "mo:base/Array";

func reverse<A>(xs : [A]) : [A] {
  let size = xs.size();
  Array.tabulate(size, func (n : Nat) : A {
    xs[size - 1 - n];
  });
};
```
https://forum.dfinity.org/t/reversing-an-array/12724


## Find in Trie

```
import Array "mo:base/Array";

Array.find<MealTypeId>(v.mealTypeIds, func(x) { x == mealTypeId }) != null
```
