Multiplication tables: Difference between revisions

Content added Content deleted
(→‎{{header|APL}}: Removed faulty APL solution)
m (→‎{{header|Sidef}}: updated code)
Line 3,928: Line 3,928:


=={{header|Sidef}}==
=={{header|Sidef}}==
<lang ruby>var max = 12;
<lang ruby>var max = 12
var width = (max**2 -> len+1);
var width = (max**2 -> len+1)
 

func fmt_row(*items) {
func fmt_row(*items) {
items.map { |s| "%*s" % (width, s) }.join('');
items.map {|s| "%*s" % (width, s) }.join
}
}
 
say fmt_row('x┃', (1..max)...)
say "#{'━' * (width - 1)}╋#{'━' * (max * width)}"


{ |i| 
say fmt_row('x┃', (1..max)...);
say "#{'━' * (width - 1)}╋#{'━' * (max * width)}";
say fmt_row("#{i}┃", {|j| i <= j ? i*j : ''}.map(1..max)...)
} << 1..max</lang>

max.times { |i|
say fmt_row("#{i}┃", (1..max).map {|j| i <= j ? i*j : ''}...);
};</lang>
{{out}}
{{out}}
<pre>
<pre>