Skip to content

Instantly share code, notes, and snippets.

@ivirshup
Created May 19, 2016 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivirshup/e9148f01663278ca4972d8a2d9715f72 to your computer and use it in GitHub Desktop.
Save ivirshup/e9148f01663278ca4972d8a2d9715f72 to your computer and use it in GitHub Desktop.
Function to completely flatten nested arrays in julia. Surprisingly efficient.
function flattenall(a::AbstractArray)
while any(x->typeof(x)<:AbstractArray, a)
a = collect(Base.flatten(a))
end
return a
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment