Skip to content

Commit 651ffc7

Browse files
committed
Merge pull request #50 from jplatte/master
Update nub / nubBy documentation and unit test to consider element order
2 parents a19f127 + efd571b commit 651ffc7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

docs/Data/Array.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,17 @@ specified equivalence relation to detemine equality.
453453
nub :: forall a. (Eq a) => Array a -> Array a
454454
```
455455

456+
Special case of `nubBy`: `nubBy eq`
457+
456458
#### `nubBy`
457459

458460
``` purescript
459461
nubBy :: forall a. (a -> a -> Boolean) -> Array a -> Array a
460462
```
461463

462464
Remove the duplicates from an array, where element equality is determined
463-
by the specified equivalence relation, creating a new array.
465+
by the specified equivalence relation, creating a new array. The first
466+
occurence of an element is always the one that is kept.
464467

465468
#### `union`
466469

@@ -566,5 +569,3 @@ second components.
566569
``` purescript
567570
foldM :: forall m a b. (Monad m) => (a -> b -> m a) -> a -> Array b -> m a
568571
```
569-
570-

test/Test/Data/Array.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ testArray = do
233233
log "groupBy should group consecutive equal elements into arrays based on an equivalence relation"
234234
assert $ groupBy (\x y -> odd x && odd y) [1, 1, 2, 2, 3, 3] == [[1, 1], [2], [2], [3, 3]]
235235

236-
log "nub should remove duplicate items from the list"
236+
log "nub should remove duplicate elements from the list, keeping the first occurence"
237237
assert $ nub [1, 2, 2, 3, 4, 1] == [1, 2, 3, 4]
238238

239239
log "nubBy should remove duplicate items from the list using a supplied predicate"

0 commit comments

Comments
 (0)