Add drawing code and elementwise reduction.
This commit is contained in:
parent
a5e6c4c145
commit
6fc6c5cf53
@ -7,6 +7,12 @@ class Array(T)
|
||||
dest
|
||||
end
|
||||
|
||||
def reduce_elementwise(&block)
|
||||
reduce do |l, r|
|
||||
l.zip_with(r) { |a, b| yield a, b }
|
||||
end
|
||||
end
|
||||
|
||||
def union
|
||||
reduce(T.new) do |l, r|
|
||||
l | r
|
||||
@ -18,6 +24,15 @@ class Array(T)
|
||||
l & r
|
||||
end
|
||||
end
|
||||
|
||||
def draw(width, maps)
|
||||
self.each_slice(width) do |slice|
|
||||
slice.each do |c|
|
||||
print maps[c]
|
||||
end
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
struct Tuple(*T)
|
||||
|
Loading…
Reference in New Issue
Block a user