Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

[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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant