Created
May 22, 2018 20:28
-
-
Save regiskuckaertz/ba0efa80e39dc12e041defbafe27ae74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
series :: Int -> [Int] | |
series n = go where go = n : (zipWith (+) go $ fmap mirror go) | |
mirror :: Int -> Int | |
mirror = undigits . digits | |
digits :: Int -> [Int] | |
digits = map (`mod` 10) . takeWhile (/= 0) . iterate (`div` 10) | |
undigits :: [Int] -> Int | |
undigits = foldl' f 0 where f r i = 10 * r + i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment