Skip to content

Commit

Permalink
windowed 2 is like pairwise
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 29, 2015
1 parent ce4c1e8 commit 0f46604
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/fsharp/FSharp.Core.PropertyTests/ListProperties.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ let ``chunkBySize is reversable with collect`` () =
Check.QuickThrowOnFailure chunkBySize_and_collect<string>
Check.QuickThrowOnFailure chunkBySize_and_collect<NormalFloat>

let windowed_and_pairwise<'a when 'a : equality> (xs : 'a list) =
let a = List.windowed 2 xs
let b = List.pairwise xs |> List.map (fun (x,y) -> [x;y])

a = b

[<Test>]
let ``windowed 2 is like pairwise`` () =
Check.QuickThrowOnFailure windowed_and_pairwise<int>
Check.QuickThrowOnFailure windowed_and_pairwise<string>
Check.QuickThrowOnFailure windowed_and_pairwise<NormalFloat>

[<Test>]
let ``chunkBySize produces chunks exactly of size `chunkSize`, except the last one, which can be smaller, but not empty``() =
let prop (a: _ list) (PositiveInt chunkSize) =
Expand Down

0 comments on commit 0f46604

Please sign in to comment.