Skip to content

Commit

Permalink
Merge pull request #15741 from eschnett/eschnett/unique
Browse files Browse the repository at this point in the history
Document `unique(itr)`
  • Loading branch information
eschnett committed Apr 2, 2016
2 parents f5b4e2e + 4898c2e commit 8c17d60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions base/set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ const ⊆ = issubset
(l::Set, r::Set) = <(l, r)
(l::Set, r::Set) = !(l, r)

"""
unique(itr)
Returns an array containing one value from `itr` for each unique value,
as determined by `isequal`.
"""
function unique(C)
out = Vector{eltype(C)}()
seen = Set{eltype(C)}()
Expand Down
6 changes: 6 additions & 0 deletions doc/stdlib/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ Iterable Collections
Returns an array containing only the unique elements of the iterable ``itr``\ , in the order that the first of each set of equivalent elements originally appears. If ``dim`` is specified, returns unique regions of the array ``itr`` along ``dim``\ .

.. function:: unique(itr)

.. Docstring generated from Julia source
Returns an array containing one value from ``itr`` for each unique value, as determined by ``isequal``\ .

.. function:: unique(f, itr)

.. Docstring generated from Julia source
Expand Down

0 comments on commit 8c17d60

Please sign in to comment.