Created
January 1, 2019 19:14
-
-
Save thealmarty/0eaaf064a5ecbf38991b781f4b6ae4c4 to your computer and use it in GitHub Desktop.
A modified zip function in Haskell that sums up the two elements of the input lists in the second item of the output tuple.
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
--As modified from the Prelude: | |
zip_sum ::(Num a, Eq a)=> [a] -> [a] -> [(a,a)] | |
zip_sum [] _bs = [] | |
zip_sum _as [] = [] | |
zip_sum (a:as) (b:bs) = (a, (a + b) ) : zip_sum as bs | |
main = do | |
print (zip_sum [0,1,2] [1,2,3]) | |
print (zip_sum [1,2,3,4,0,5,6] [1,2,3,4,5,6,0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See my blog post.