-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Adding unique!
functionality
#20576
Changes from 1 commit
efa33b7
e973e8b
97b4797
905e877
892552b
95e4c19
1183329
9ff810c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,23 @@ function unique(f::Callable, C) | |
out | ||
end | ||
|
||
""" | ||
unique!(itr) | ||
|
||
Removes recurrences of items and returns the modified collection | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use imperative "Remove" and add ending dot. Also, better say "duplicated items" rather than "recurrence". Finally, would be worth saying a word about the fact that |
||
""" | ||
function unique!(itr) | ||
seen = Set{eltype(itr)}() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use 4 spaces rather than tabs for indentation for consistency with the rest of the repo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should have noted that, will update it in the next commit |
||
for (i, x) in enumerate(itr) | ||
if x in seen | ||
deleteat!(itr, i) | ||
else | ||
push!(seen, x) | ||
end | ||
end | ||
return itr | ||
end | ||
|
||
""" | ||
allunique(itr) -> Bool | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing elements is generally not possible on iterators, so better replace
itr
withc
(for collection).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signature has been changed, but not the signature in the docstring. The docstring should also be updated.