Skip to content

Instantly share code, notes, and snippets.

@gavinwahl
Created April 27, 2011 00:22
Show Gist options
  • Save gavinwahl/943477 to your computer and use it in GitHub Desktop.
Save gavinwahl/943477 to your computer and use it in GitHub Desktop.
expand (Plus a) = foldr interleave [] $ do
match <- expand a
return $ match:(map (match++) (expand (Plus a)))
expand (Plus a) = (concat . ap (iterate . liftM2 (++) . expand) expand) a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment