Created
November 27, 2014 19:37
-
-
Save astarasikov/faf14862ae23259210c8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let rec revZipWithDefault accum dval lsta lstb = | |
match lsta with | |
| ha :: ta -> | |
(match lstb with | |
| hb :: tb -> zipWithDefault ((ha, hb) :: accum) dval ta tb | |
| _ -> zipWithDefault ((ha, dval) :: accum) dval ta []) | |
| _ -> | |
(match lstb with | |
| hd :: tl -> zipWithDefault ((dval, hd) :: accum) dval [] tl | |
| _ -> accum);; | |
let zipInts a b = revZipWithDefault [] 0 a b |> List.rev;; | |
zipInts [1;2;3] [4;5] |> map (fun (a, b) -> a + b);; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment