@@ -244,6 +244,18 @@ testNonEmptyArray = do
244
244
let oneToSeven = fromArray [1 , 2 , 3 , 4 , 5 , 6 , 7 ]
245
245
testSpan { p: (_ < 4 ), input: oneToSeven, init_: [1 , 2 , 3 ], rest_: [4 , 5 , 6 , 7 ] }
246
246
247
+ log " group should group consecutive equal elements into arrays"
248
+ assert $ NEA .group (fromArray [1 , 2 , 2 , 3 , 3 , 3 , 1 ]) == fromArray [NEA .singleton 1 , fromArray [2 , 2 ], fromArray [3 , 3 , 3 ], NEA .singleton 1 ]
249
+
250
+ log " group' should sort then group consecutive equal elements into arrays"
251
+ assert $ NEA .group' (fromArray [1 , 2 , 2 , 3 , 3 , 3 , 1 ]) == fromArray [fromArray [1 , 1 ], fromArray [2 , 2 ], fromArray [3 , 3 , 3 ]]
252
+
253
+ log " groupBy should group consecutive equal elements into arrays based on an equivalence relation"
254
+ assert $ NEA .groupBy (\x y -> odd x && odd y) (fromArray [1 , 1 , 2 , 2 , 3 , 3 ]) == fromArray [fromArray [1 , 1 ], NEA .singleton 2 , NEA .singleton 2 , fromArray [3 , 3 ]]
255
+
256
+ log " groupBy should be stable"
257
+ assert $ NEA .groupBy (\_ _ -> true ) (fromArray [1 , 2 , 3 ]) == fromArray [fromArray [1 , 2 , 3 ]]
258
+
247
259
log " nub should remove duplicate elements from the list, keeping the first occurence"
248
260
assert $ NEA .nub (fromArray [1 , 2 , 2 , 3 , 4 , 1 ]) == fromArray [1 , 2 , 3 , 4 ]
249
261
0 commit comments