Skip to content

Instantly share code, notes, and snippets.

@Gerhut
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

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

Select an option

Save Gerhut/066eb202388d851ead1b to your computer and use it in GitHub Desktop.
flatten = (list) ->
result = []
lists = []
while list? and not list in lists
lists.push list
result.push list[0]
list = list[1]
return result
console.log flatten [1, ['foo', [(->), [a: no, [new Date, [/bar/g]]]]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment