Skip to content

Commit

Permalink
zip3 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 3661147 commit 82d9c6a
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1173,4 +1173,19 @@ let zip<'a when 'a : equality> (xs':('a*'a) []) =
let ``zip is consistent for collections with equal length`` () =
Check.QuickThrowOnFailure zip<int>
Check.QuickThrowOnFailure zip<string>
Check.QuickThrowOnFailure zip<NormalFloat>
Check.QuickThrowOnFailure zip<NormalFloat>

let zip3<'a when 'a : equality> (xs':('a*'a*'a) []) =
let xs = Array.map (fun (x,y,z) -> x) xs'
let xs2 = Array.map (fun (x,y,z) -> y) xs'
let xs3 = Array.map (fun (x,y,z) -> z) xs'
let s = runAndCheckErrorType (fun () -> Seq.zip3 xs xs2 xs3 |> Seq.toArray)
let l = runAndCheckErrorType (fun () -> List.zip3 (List.ofSeq xs) (List.ofSeq xs2) (List.ofSeq xs3) |> List.toArray)
let a = runAndCheckErrorType (fun () -> Array.zip3 (Array.ofSeq xs) (Array.ofSeq xs2) (Array.ofSeq xs3))
s = a && l = a

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

0 comments on commit 82d9c6a

Please sign in to comment.