Skip to content

Instantly share code, notes, and snippets.

@gdejohn
Last active May 28, 2016 11:20
Show Gist options
  • Save gdejohn/81ffafefc0ab50baa8ee to your computer and use it in GitHub Desktop.
Save gdejohn/81ffafefc0ab50baa8ee to your computer and use it in GitHub Desktop.
import Control.Applicative (liftA2)
import Control.Monad (guard)
import Data.Functor ((<$))
import Data.List (unfoldr)
import Data.Tuple (swap)
digits :: Integer -> [Integer]
digits = reverse . unfoldr (liftA2 (<$) (swap . (`divMod` 10)) (guard . (> 0)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment