Skip to content

Commit

Permalink
zip is consistent for collections with equal length
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 29, 2015
1 parent 76a41d4 commit 3661147
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1160,3 +1160,17 @@ let ``windowed is consistent`` () =
Check.QuickThrowOnFailure windowed<int>
Check.QuickThrowOnFailure windowed<string>
Check.QuickThrowOnFailure windowed<NormalFloat>

let zip<'a when 'a : equality> (xs':('a*'a) []) =
let xs = Array.map fst xs'
let xs2 = Array.map snd xs'
let s = runAndCheckErrorType (fun () -> Seq.zip xs xs2 |> Seq.toArray)
let l = runAndCheckErrorType (fun () -> List.zip (List.ofSeq xs) (List.ofSeq xs2) |> List.toArray)
let a = runAndCheckErrorType (fun () -> Array.zip (Array.ofSeq xs) (Array.ofSeq xs2))
s = a && l = a

[<Test>]
let ``zip is consistent for collections with equal length`` () =
Check.QuickThrowOnFailure zip<int>
Check.QuickThrowOnFailure zip<string>
Check.QuickThrowOnFailure zip<NormalFloat>

0 comments on commit 3661147

Please sign in to comment.