Skip to content

Commit

Permalink
max is consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 29, 2015
1 parent 88aa02e commit 58cbd87
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,18 @@ let ``mapi2 looks at every element exactly once and in order - consistenly over
Check.QuickThrowOnFailure mapi2<string>
Check.QuickThrowOnFailure mapi2<NormalFloat>

let max<'a when 'a : comparison> (xs : 'a []) =
let s = runAndCheckIfAnyError (fun () -> xs |> Seq.max)
let l = runAndCheckIfAnyError (fun () -> xs |> List.ofArray |> List.max)
let a = runAndCheckIfAnyError (fun () -> xs |> Array.max)
s = a && l = a

[<Test>]
let ``max is consistent`` () =
Check.QuickThrowOnFailure max<int>
Check.QuickThrowOnFailure max<string>
Check.QuickThrowOnFailure max<NormalFloat>

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 58cbd87

Please sign in to comment.