Created
January 9, 2019 21:21
-
-
Save emilypi/46ad088df3d81605c5308508ad0c5d09 to your computer and use it in GitHub Desktop.
Tony's problem
This file contains hidden or 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
reverse'' :: Int -> [a] -> [a] -> [a] | |
reverse'' n [] rs = drop n rs | |
reverse'' n as rs = h : t | |
where | |
h = case as of (a : as) -> head $ reverse'' n as (a : rs) | |
t = case as of (a : as) -> reverse'' (n + 1) as (a : rs) | |
reverse' :: [a] -> [a] | |
reverse' x = reverse'' 0 x [] | |
main :: IO () | |
main = do | |
print $ reverse' $ [1..10] | |
print $ length . take 1 . reverse' . reverse' $ [1..] | |
print $ length . take 50000 . reverse' . reverse' $ [1..] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment