Skip to content

Commit

Permalink
scanBack is consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 29, 2015
1 parent b43109f commit a379e73
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,19 @@ let ``scan is consistent`` () =
Check.QuickThrowOnFailure scan<float,int>
Check.QuickThrowOnFailure scan<float,string>

let scanBack<'a,'b when 'b : equality> (xs : 'a []) f (start:'b) =
let s = run (fun () -> Seq.scanBack f xs start |> Seq.toArray)
let l = run (fun () -> List.scanBack f (xs |> List.ofArray) start |> Seq.toArray)
let a = run (fun () -> Array.scanBack f xs start)
s = a && l = a

[<Test>]
let ``scanBack is consistent`` () =
Check.QuickThrowOnFailure scanBack<int,int>
Check.QuickThrowOnFailure scanBack<string,string>
Check.QuickThrowOnFailure scanBack<float,int>
Check.QuickThrowOnFailure scanBack<float,string>

let sort<'a when 'a : comparison> (xs : 'a []) =
let s = xs |> Seq.sort
let l = xs |> List.ofArray |> List.sort
Expand Down

0 comments on commit a379e73

Please sign in to comment.