Created
January 1, 2019 18:57
-
-
Save thealmarty/2db0423a157648083ccb89cc278ebc2a to your computer and use it in GitHub Desktop.
A modified zip function in Haskell that output a list with the second input list's element repeated.
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_repeat_input2 ::(Num a, Eq a, Num b, Eq b)=> [a] -> [b] -> [(a,b,b)] | |
zip_repeat_input2 [] _bs = [] | |
zip_repeat_input2 _as [] = [] | |
zip_repeat_input2 (a:as) (b:bs) = (a,b,b) : zip_repeat_input2 as bs | |
main = do | |
print (zip_repeat_input2 [0,1,2] [1,2,3]) | |
print (zip_repeat_input2 [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.