Add drawing code and elementwise reduction.

This commit is contained in:
Danila Fedorin 2020-12-07 18:42:44 -08:00
parent a5e6c4c145
commit 6fc6c5cf53

View File

@ -7,6 +7,12 @@ class Array(T)
dest dest
end end
def reduce_elementwise(&block)
reduce do |l, r|
l.zip_with(r) { |a, b| yield a, b }
end
end
def union def union
reduce(T.new) do |l, r| reduce(T.new) do |l, r|
l | r l | r
@ -18,6 +24,15 @@ class Array(T)
l & r l & r
end end
end end
def draw(width, maps)
self.each_slice(width) do |slice|
slice.each do |c|
print maps[c]
end
puts
end
end
end end
struct Tuple(*T) struct Tuple(*T)