Skip to content

Instantly share code, notes, and snippets.

@thealmarty
Created January 1, 2019 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thealmarty/2db0423a157648083ccb89cc278ebc2a to your computer and use it in GitHub Desktop.
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.
--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])
@thealmarty
Copy link
Author

See my blog post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment