Effect CommunityEC
Effect Community3y ago
7 replies
Stephen Bluck

Flattening Nested Arrays in FP Style

Is there an FP way to flatten an array like so?
// Turn this...
const Decks = [{ id: 1, subdecks: [{ id: 2, subdecks: [{ id: 3, subdecks: []}]}]}]

// Into this...
const result = [{id: 1}, {id: 2}, {id: 3}]
Was this page helpful?