Average loop length: Difference between revisions
Content deleted Content added
→{{header|Wren}}: 'as' is now a keyword, better to use Fmt.print anyway. |
|||
Line 3,549: | Line 3,549: | ||
{{libheader|Wren-fmt}} |
{{libheader|Wren-fmt}} |
||
<syntaxhighlight lang="ecmascript">import "random" for Random |
<syntaxhighlight lang="ecmascript">import "random" for Random |
||
import "/fmt" for Fmt |
import "./fmt" for Fmt |
||
var nmax = 20 |
var nmax = 20 |
||
Line 3,585: | Line 3,585: | ||
var a = avg.call(n) |
var a = avg.call(n) |
||
var b = ana.call(n) |
var b = ana.call(n) |
||
var ns = Fmt.d(3, n) |
|||
var as = Fmt.f(9, a, 4) |
|||
var bs = Fmt.f(12, b, 4) |
|||
var e = (a - b).abs/ b * 100 |
var e = (a - b).abs/ b * 100 |
||
Fmt.print("$3d $9.4f $12.4f ($6.2f\%)", n, a, b, e) |
|||
System.print("%(ns) %(as) %(bs) (%(es)\%)") |
|||
}</syntaxhighlight> |
}</syntaxhighlight> |
||