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

14 lines
298 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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