Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
Last active August 29, 2015 14:11
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 TheSeamau5/beacaccd06188453e537 to your computer and use it in GitHub Desktop.
Save TheSeamau5/beacaccd06188453e537 to your computer and use it in GitHub Desktop.
Interleave two lists in Elm
interleave : List a -> List a -> List a
interleave list1 list2 =
case list1 of
[] -> list2
x :: xs ->
case list2 of
[] -> list1
y :: ys -> y :: x :: interleave xs ys
@TheSeamau5
Copy link
Author

Example:

interleave [2,4,6] [1,3,5] == [1,2,3,4,5,6] 

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