Add a zip_with function.
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
class Array(T)
|
||||
def zip_with(other : Array(R), &block : T, R -> U) forall R, U
|
||||
dest = [] of U
|
||||
zip(other) do |l, r|
|
||||
dest << yield l, r
|
||||
end
|
||||
dest
|
||||
end
|
||||
|
||||
def union
|
||||
reduce(T.new) do |l, r|
|
||||
l | r
|
||||
|
||||
Reference in New Issue
Block a user