Skip to content
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

table.deduplicate(d) #554

Open
Sainan opened this issue Dec 15, 2023 · 3 comments
Open

table.deduplicate(d) #554

Sainan opened this issue Dec 15, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@Sainan
Copy link
Collaborator

Sainan commented Dec 15, 2023

Removes duplicate values from a table

@Sainan Sainan added the enhancement New feature or request label Dec 15, 2023
@well-in-that-case
Copy link
Collaborator

Seems like a niche enough operation for filter + another table to handle tbh

@Sainan Sainan closed this as not planned Won't fix, can't repro, duplicate, stale Dec 16, 2023
@Sainan
Copy link
Collaborator Author

Sainan commented Dec 19, 2023

Ehhh

table.uniques = function(t)
    local seen = {}
    t:filter(function(x)
        if seen:contains(x) then return false end
        seen:insert(x)
        return true
    end)
    return t
end

@Sainan Sainan reopened this Dec 19, 2023
@Sainan
Copy link
Collaborator Author

Sainan commented Dec 19, 2023

Although might need a different name such as table.deduplicate or table.dedup so we can have table.deduplicated or table.deduped for the copying variant.

@Sainan Sainan changed the title table.uniques table.deduplicate(d) Jan 21, 2024
@Sainan Sainan modified the milestone: 0.9.0 Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants