Write a function that accepts a multi dimensional array and returns a flattened version.
flatten([1, 2, [3, [4], 5, 6], 7]) // [1, 2, 3, 4, 5, 6, 7]
If solving in Haskell
, please use the following datatype:
data NestedList a = Elem a | List [NestedList a]