Skip to content

Instantly share code, notes, and snippets.

@Gerhut
Created August 8, 2014 00:41
Show Gist options
  • Select an option

  • Save Gerhut/ff5828d88d5ea86b7546 to your computer and use it in GitHub Desktop.

Select an option

Save Gerhut/ff5828d88d5ea86b7546 to your computer and use it in GitHub Desktop.
flatten = (list, result = []) ->
for value in list
if Array.isArray value
flatten value, result
else
result.push value
return result
console.log flatten [(->), [[new Date], /foo/g]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment