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

14 lines
298 B
Text
Raw Permalink Normal View History

2017-09-23 10:01:46 +02:00
var max = 12
var width = (max**2 -> len+1)
 
2016-12-05 23:44:36 +01:00
func fmt_row(*items) {
2017-09-23 10:01:46 +02:00
items.map {|s| "%*s" % (width, s) }.join
2016-12-05 23:44:36 +01:00
}
2017-09-23 10:01:46 +02:00
 
say fmt_row('x┃', (1..max)...)
say "#{'━' * (width - 1)}╋#{'━' * (max * width)}"
2016-12-05 23:44:36 +01:00
2017-09-23 10:01:46 +02:00
{ |i| 
say fmt_row("#{i}┃", {|j| i <= j ? i*j : ''}.map(1..max)...)
} << 1..max