RosettaCodeData/Task/Multiplication-tables/Sidef/multiplication-tables.sidef

14 lines
298 B
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var max = 12
var width = (max**2 -> len+1)
 
func fmt_row(*items) {
items.map {|s| "%*s" % (width, s) }.join
}
 
say fmt_row('x┃', (1..max)...)
say "#{'━' * (width - 1)}╋#{'━' * (max * width)}"
{ |i| 
say fmt_row("#{i}┃", {|j| i <= j ? i*j : ''}.map(1..max)...)
} << 1..max