def partition(f, li, ys=[], zs=[])
return ys, zs if li.empty?
x, *xs = li
return partition(f, xs, [*ys, x], zs) if f.call(x)
partition(f, xs, ys, [*zs, x])
end
p partition(->(x){x%2==1}, [1,2,3,4,5,6])
To embed this project on your website, copy the following code and paste it into your website's HTML: