Horse racing: Difference between revisions
m
→{{header|Wren}}: Minor tidy
No edit summary |
m (→{{header|Wren}}: Minor tidy) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 82:
=={{header|Go}}==
{{trans|Wren}}
<
import (
Line 177:
sec := t - float64(min)*60
fmt.Printf("\nTime %d minute %3.1f seconds\n", min, sec)
}</
{{out}}
Line 200:
=={{header|Julia}}==
{{trans|Go}}
<
# ratings on past form, assuming a rating of 100 for horse A
a = 100
Line 262:
main()
</
<pre>
Race 4
Line 283:
=={{header|Nim}}==
{{trans|Wren}}
<
# Ratings on past form, assuming a rating of 100 for horse A.
Line 341:
var min = int(t / 60)
var sec = t mod 60
echo &"\nTime {min} minute {sec:.1f} seconds"</
{{out}}
Line 362:
=={{header|Perl}}==
{{trans|Raku}}
<
use warnings;
Line 402:
}
print for sort @predictions;</
{{out}}
<pre> 1 i Iphigenia in Brooklyn 8.11 0.0 filly 1:35.4
Line 418:
Disclaimer: I know nothing about horse racing, all calculations were reverse-engineered from those in the Go entry.<br>
Made table-based so you can plug in different races and adjustments, but any horse appearing in more than one race input would too in the output.
<!--<
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #7060A8;">requires</span> <span style="color: #0000FF;">(</span><span style="color: #008000;">"1.0.1"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">// [else sort_columns() needs a deep_copy()]</span>
Line 482:
<span style="color: #000000;">s</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">elapsed</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">remainder</span><span style="color: #0000FF;">(</span><span style="color: #000000;">t</span><span style="color: #0000FF;">,</span><span style="color: #000000;">60</span><span style="color: #0000FF;">))</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\nTime %s %s\n"</span><span style="color: #0000FF;">,</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">m</span><span style="color: #0000FF;">,</span><span style="color: #000000;">s</span><span style="color: #0000FF;">})</span>
<!--</
{{out}}
<pre>
Line 504:
=={{header|Raku}}==
I know nothing about horse racing and/or handicapping. This is mostly a straightforward translation of the logic from Go though I did take certain liberties with formatting and layout.
<syntaxhighlight lang="raku"
%card<a> = { name => 'Alberta Clipper', :sex<M>, rating => 100 };
%card<b> = { name => 'Beetlebaum', :sex<F>, rating => %card<a><rating> - 8 - 2*2 };
Line 540:
printf "%2d %s %-22s %.2f %.1f %-6s %s\n", $position, .key, .value<name>, .value<weight>,
.value<back>, .value<sex> eq 'M' ?? 'colt' !! 'filly', .value.<time>.polymod(60 xx*).reverse.join: ':';
}</
{{out}}
<pre>Pos Horse Name Weight Back Sex Time
Line 554:
9 g Grindstone 9.00 7.0 colt 1:36.8</pre>
=={{header|V (Vlang)}}==
{{trans|go}}
<syntaxhighlight lang="v (vlang)">struct Kv {
key string
value []f64
Line 651:
sec := t - f64(min)*60
println("\nTime $min minute ${sec:3.1f} seconds")
}</
{{out}}
<pre>Same as go entry</pre>
Line 657:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<
// ratings on past form, assuming a rating of 100 for horse A
Line 721:
var min = (t/60).floor
var sec = t % 60
System.print("\nTime %(min) minute %(sec) seconds")</
{{out}}
|