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

[Feature request]: Data partition #18

Open
lopi-py opened this issue Dec 29, 2023 · 0 comments
Open

[Feature request]: Data partition #18

lopi-py opened this issue Dec 29, 2023 · 0 comments

Comments

@lopi-py
Copy link

lopi-py commented Dec 29, 2023

I find myself doing this often:

local numbers = { 1, 4, 2, 3, 1, 1, 3 }
local ones = Sift.Array.filter(numbers, function(number)
    return number == 1
end)
local noOnes = Sift.Array.filter(numbers, function(number)
    return number ~= 1
end)

It would be nice to have a partition/split method to separate data:

local numbers = { 1, 4, 2, 3, 1, 1, 3 }
local ones, noOnes = Sift.Array.partition(numbers, function(number)
    return number == 1
end)

print(ones) -- { 1, 1, 1 }
print(noOnes) -- { 4, 2, 3, 3 }

It could also apply for Set and Dictionary

@cxmeel cxmeel mentioned this issue Mar 12, 2024
7 tasks
cxmeel added a commit that referenced this issue Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant