[Feature request]: Data partition
lopi-py opened this issue · comments
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