Skip to content

Commit

Permalink
minBy is opposite of maxBy
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 29, 2015
1 parent 5b91e1a commit 35860ba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/fsharp/FSharp.Core.PropertyTests/ListProperties.fs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,17 @@ let min_and_max (xs : list<int>) =
let ``min is opposite of max`` () =
Check.QuickThrowOnFailure min_and_max

let minBy_and_maxBy (xs : list<int>) f =
let a = run (fun () -> List.minBy f xs)
let b = run (fun () -> xs |> List.map ((*) -1) |> List.maxBy f |> fun x -> -x)

a = b

[<Test>]
let ``minBy is opposite of maxBy`` () =
Check.QuickThrowOnFailure minBy_and_maxBy


let min_and_sort<'a when 'a : comparison> (xs : list<'a>) =
let a = runAndCheckErrorType (fun () -> List.min xs)
let b = runAndCheckErrorType (fun () -> xs |> List.sort |> List.head)
Expand Down

0 comments on commit 35860ba

Please sign in to comment.