First-class functions/Use numbers analogously: Difference between revisions
First-class functions/Use numbers analogously (view source)
Revision as of 10:52, 14 March 2020
, 4 years agoRename Perl 6 -> Raku, alphabetize, minor clean-up
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
|||
Line 358:
Note: <code>def g := reverse[i]</code> is needed here because E as yet has no defined protocol for iterating over collections in parallel. [http://wiki.erights.org/wiki/Parallel_iteration Page for this issue.]
=={{header|Elena}}==
{{trans|C#}}
Line 896 ⟶ 897:
6.00 * 0.17 * 0.50 = 0.50
</pre>
=={{header|Mathematica}} / {{header|Wolfram Language}}==
Line 1,128:
compose($flist1[$_], $flist2[$_]) -> (0.5)
</lang>
=={{header|Perl 6}}==▼
{{works with|Rakudo|2015-09-10}}▼
<lang perl6>sub multiplied ($g, $f) { return { $g * $f * $^x } }▼
my $x = 2.0;▼
my $xi = 0.5;▼
my $y = 4.0;▼
my $yi = 0.25;▼
my $z = $x + $y;▼
my $zi = 1.0 / ( $x + $y );▼
my @numbers = $x, $y, $z;▼
my @inverses = $xi, $yi, $zi;▼
for flat @numbers Z @inverses { say multiplied($^g, $^f)(.5) }</lang>▼
Output:▼
<pre>0.5▼
0.5▼
0.5</pre>▼
The structure of this is identical to first-class function task.▼
=={{header|Phix}}==
Line 1,329 ⟶ 1,308:
;; -> '(0.5 0.5 0.5)
</lang>
(formerly Perl 6)
▲{{works with|Rakudo|2015-09-10}}
▲<lang perl6>sub multiplied ($g, $f) { return { $g * $f * $^x } }
▲my $x = 2.0;
▲my $xi = 0.5;
▲my $y = 4.0;
▲my $yi = 0.25;
▲my $z = $x + $y;
▲my $zi = 1.0 / ( $x + $y );
▲my @numbers = $x, $y, $z;
▲my @inverses = $xi, $yi, $zi;
▲for flat @numbers Z @inverses { say multiplied($^g, $^f)(.5) }</lang>
▲Output:
▲<pre>0.5
▲0.5
▲0.5</pre>
▲The structure of this is identical to first-class function task.
=={{header|REXX}}==
|