Created
February 22, 2020 13:31
-
-
Save thalesmg/8524bf898a9dca6020af3db40a1e1365 to your computer and use it in GitHub Desktop.
There and back again (TABA)
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
-- https://doisinkidney.com/posts/2020-02-15-taba.html | |
zipRev :: [a] -> [b] -> [(a,b)] | |
zipRev xs ys = foldl f b ys xs | |
where | |
b _ = [] | |
f k y (x:xs) = (x,y) : k xs | |
f k y [] = [] | |
{- | |
zipRev [1,2,3] [10,20,30] = | |
foldl f b [10,20,30] [1,2,3] = | |
(f (f (f b 10) 20) 30) [1,2,3] = | |
(1,30) : (f (f b 10) 20) [2,3] = | |
(1,30) : (2, 20) : (f b 10) [3] = | |
(1,30) : (2, 20) : (3, 10) : b [] = | |
(1,30) : (2, 20) : (3, 10) : [] = | |
[(1,30), (2,20), (3,10)] | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment