Skip to content

Instantly share code, notes, and snippets.

@Lifelovinglight
Last active April 23, 2019 20:24
Show Gist options
  • Save Lifelovinglight/8604744777ab978348be990fa4419e8b to your computer and use it in GitHub Desktop.
Save Lifelovinglight/8604744777ab978348be990fa4419e8b to your computer and use it in GitHub Desktop.
unfold :: (a -> Bool) -> (a -> a) -> a -> [a]
unfold stop step init | stop init = []
| otherwise = init : unfold stop step (step init)
modulo = curry $ length . unfold (uncurry (>)) (\dn -> subtract (fst dn) <$> dn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment