-
Notifications
You must be signed in to change notification settings - Fork 104
Add zipShortest function and make generic Zip safe #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
fb225ff
d90f750
b3a1c59
7e95ff4
c2c99f2
3895f6f
700e88e
15326d7
d6aa67a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,3 +86,15 @@ module ResizeArray = | |
| let (x, y) = ResizeArray (), ResizeArray () | ||
| Array.iter (mapper >> function Choice1Of2 e -> x.Add e | Choice2Of2 e -> y.Add e) source | ||
| x.ToArray (), y.ToArray () | ||
|
|
||
|
|
||
| /// <summary> | ||
| /// Zip safely two ResizeArrays. If one ResizeArray is shorter, excess elements are discarded from the right end of the longer ResizeArray. | ||
| /// </summary> | ||
| /// <param name="a1">First input ResizeArray.</param> | ||
| /// <param name="a2">Second input ResizeArray.</param> | ||
| /// <returns>ResizeArray with corresponding pairs of input ResizeArrays.</returns> | ||
| let zipShortest (a1: ResizeArray<'T1>) (a2: ResizeArray<'T2>) = | ||
3Rafal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let len = min a1.Count a2.Count | ||
| [| for i in 0..(len-1) -> a1.[i], a2.[i] |] | ||
| |> ResizeArray | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.