Worthwhile task shaving: Difference between revisions
Content added Content deleted
No edit summary |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 17: | Line 17: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
{{trans|Perl}} |
{{trans|Perl}} |
||
< |
<syntaxhighlight lang="julia">shaved = [1, 5, 30, 60, 300, 1800, 3600, 21600, 86400] |
||
columns = [" 1 Second", " 5 Seconds", "30 Seconds", " 1 Minute", " 5 Minutes", "30 Minutes", " 1 Hour", " 6 Hours", " 1 Day"] |
columns = [" 1 Second", " 5 Seconds", "30 Seconds", " 1 Minute", " 5 Minutes", "30 Minutes", " 1 Hour", " 6 Hours", " 1 Day"] |
||
diy, minute, hour, day, week = 365.25, 60, 60 * 60, 60 * 60 * 24, 60 * 60 * 24 * 7 |
diy, minute, hour, day, week = 365.25, 60, 60 * 60, 60 * 60 * 24, 60 * 60 * 24 * 7 |
||
Line 38: | Line 38: | ||
println(row) |
println(row) |
||
end |
end |
||
</ |
</syntaxhighlight>{{out}} |
||
<pre> |
<pre> |
||
How Often You Do the Task |
How Often You Do the Task |
||
Line 57: | Line 57: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
< |
<syntaxhighlight lang="perl">use strict; |
||
use warnings; |
use warnings; |
||
use feature <say switch>; |
use feature <say switch>; |
||
Line 92: | Line 92: | ||
} |
} |
||
say $row; |
say $row; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> How Often You Do the Task |
<pre> How Often You Do the Task |
||
Line 109: | Line 109: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
<!--< |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
||
<span style="color: #008080;">constant</span> <span style="color: #000000;">SEC</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> |
<span style="color: #008080;">constant</span> <span style="color: #000000;">SEC</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> |
||
Line 148: | Line 148: | ||
<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;">"%s\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">line</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;">"%s\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">line</span><span style="color: #0000FF;">)</span> |
||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{out}} |
{{out}} |
||
One outlier here is 1hr 5/day ==> 3 years vs original 10 months: as per notes above for 5/8ths the cutoff is indeed 3 years.<br> |
One outlier here is 1hr 5/day ==> 3 years vs original 10 months: as per notes above for 5/8ths the cutoff is indeed 3 years.<br> |
||
Line 167: | Line 167: | ||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
{{trans|Wren}} |
{{trans|Wren}} |
||
<lang |
<syntaxhighlight lang="raku" line># 20220207 Raku programming solution |
||
my \shaved = [1, 5, 30, 60, 300, 1800, 3600, 21600, 86400]; # time shaved off in seconds |
my \shaved = [1, 5, 30, 60, 300, 1800, 3600, 21600, 86400]; # time shaved off in seconds |
||
Line 203: | Line 203: | ||
} |
} |
||
print "\n" |
print "\n" |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 222: | Line 222: | ||
=={{header|Vlang}}== |
=={{header|Vlang}}== |
||
{{trans|Wren}} |
{{trans|Wren}} |
||
< |
<syntaxhighlight lang="vlang">import math |
||
const ( |
const ( |
||
shaved = [1, 5, 30, 60, 300, 1800, 3600, 21600, 86400] // time shaved off in seconds |
shaved = [1, 5, 30, 60, 300, 1800, 3600, 21600, 86400] // time shaved off in seconds |
||
Line 274: | Line 274: | ||
println('') |
println('') |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 295: | Line 295: | ||
{{libheader|Wren-fmt}} |
{{libheader|Wren-fmt}} |
||
This is quite close to the original table but no cigar. |
This is quite close to the original table but no cigar. |
||
< |
<syntaxhighlight lang="ecmascript">import "./fmt" for Fmt |
||
var shaved = [1, 5, 30, 60, 300, 1800, 3600, 21600, 86400] // time shaved off in seconds |
var shaved = [1, 5, 30, 60, 300, 1800, 3600, 21600, 86400] // time shaved off in seconds |
||
Line 341: | Line 341: | ||
} |
} |
||
System.print() |
System.print() |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 361: | Line 361: | ||
=={{header|Yabasic}}== |
=={{header|Yabasic}}== |
||
{{trans|Phix}} |
{{trans|Phix}} |
||
< |
<syntaxhighlight lang="yabasic">// Rosetta Code problem: http://rosettacode.org/wiki/Worthwhile_task_shaving |
||
// by Galileo, 02/2022 |
// by Galileo, 02/2022 |
||
Line 402: | Line 402: | ||
next |
next |
||
print line$ |
print line$ |
||
next</ |
next</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> 50/day 5/day daily weekly monthly yearly |
<pre> 50/day 5/day daily weekly monthly yearly |