Flatten an array

·

1 min read

If your array contains Int as well as [Int], there is no easy way to flatten it.

For example: [1, 2, 3, 4, [5, 6]] is not easy to flatten. You need to write a custom recursive function. Not good. Avoid if you can.

But [[1, 2, 3], [4, 5, 6]] is easy to flatten, as it's has a type of [[Int]].