Skip to content

Instantly share code, notes, and snippets.

@metanest
Last active March 17, 2016 12:00
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 metanest/b902cd7aaa5669794ce7 to your computer and use it in GitHub Desktop.
Save metanest/b902cd7aaa5669794ce7 to your computer and use it in GitHub Desktop.
parFlatten2 :: [[a]] -> [a]
parFlatten2 lst = result
where
(result, tmp) = parFlattenLoop tmp lst
parFlattenLoop y [] = (r, [])
where
(r, t)
| null y = ([], undefined)
| otherwise = parFlattenLoop t y
parFlattenLoop y ([]:xss) = parFlattenLoop y xss
parFlattenLoop y ((x:[]):xss) = (x:r, t)
where
(r, t) = parFlattenLoop y xss
parFlattenLoop y ((x:xs):xss) = (x:r, xs:t)
where
(r, t) = parFlattenLoop y xss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment