Skip to content

Commit

Permalink
Merge pull request #50 from jplatte/master
Browse files Browse the repository at this point in the history
Update nub / nubBy documentation and unit test to consider element order
  • Loading branch information
garyb committed Sep 16, 2015
2 parents a19f127 + efd571b commit 651ffc7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions docs/Data/Array.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,17 @@ specified equivalence relation to detemine equality.
nub :: forall a. (Eq a) => Array a -> Array a
```

Special case of `nubBy`: `nubBy eq`

#### `nubBy`

``` purescript
nubBy :: forall a. (a -> a -> Boolean) -> Array a -> Array a
```

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

#### `union`

Expand Down Expand Up @@ -566,5 +569,3 @@ second components.
``` purescript
foldM :: forall m a b. (Monad m) => (a -> b -> m a) -> a -> Array b -> m a
```


2 changes: 1 addition & 1 deletion test/Test/Data/Array.purs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ testArray = do
log "groupBy should group consecutive equal elements into arrays based on an equivalence relation"
assert $ groupBy (\x y -> odd x && odd y) [1, 1, 2, 2, 3, 3] == [[1, 1], [2], [2], [3, 3]]

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

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

0 comments on commit 651ffc7

Please sign in to comment.