Closed omaus closed 2 years ago
Might be arguing about semantics, but this is the correct output i would expect from groupWhen
. It opens a new group only if the predicate is true.
No, imo it is not. No grouping applied does, imo, not mean that you get nothing back but that the original, unseparated group is returned as the only resulting subgroup.
Seq.groupWhen
and List.groupWhen
behave as expected (by me).
Seq.groupWhen isOdd [|6; 6; 2; 4; 2; 8|] // val it: seq<seq<int>> = seq [[6; 6; 2; 4; 2; 8]]
List.groupWhen isOdd [6; 6; 2; 4; 2; 8] // val it: int list list = [[6; 6; 2; 4; 2; 8]]
i stand overruled.
Description
Array.groupWhen
returns an empty array if the predicate never returnstrue
.Repro steps
Expected behavior
Returns
[|[|4;4;2;4;0;2|]|]
Actual behavior
Returns
[|[||]|]
Known workarounds
Introduce a case where the predicate returns true. Not well applicable.
Related information