First-class functions/Use numbers analogously: Difference between revisions
First-class functions/Use numbers analogously (view source)
Revision as of 23:23, 23 October 2021
, 2 years agoAdded 11l
m (→{{header|Phix}}: added syntax colouring the hard way) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 22:
<small>To paraphrase the task description: Do what was done before, but with numbers rather than functions</small>
<br><br>
=={{header|11l}}==
{{trans|Python}}
<lang 11l>V (x, xi, y, yi) = (2.0, 0.5, 4.0, 0.25)
V z = x + y
V zi = 1.0 / (x + y)
V multiplier = (n1, n2) -> (m -> @=n1 * @=n2 * m)
V numlist = [x, y, z]
V numlisti = [xi, yi, zi]
print(zip(numlist, numlisti).map((n, inversen) -> multiplier(inversen, n)(.5)))</lang>
{{out}}
<pre>
[0.5, 0.5, 0.5]
</pre>
=={{header|Ada}}==
|