Skip to content

Instantly share code, notes, and snippets.



Created Oct 24, 2019
What would you like to do?
init :: [a] -> [a]
init xs = foldr f b xs Nothing
b Nothing = error "init: empty list"
b _ = []
f x xs Nothing = xs (Just x)
f y xs (Just x) = x : xs (Just y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.