First-class functions/Use numbers analogously: Difference between revisions

Added Julia language
(Added Julia language)
Line 756:
 
As of this writing, there is no entry for jq at [[First-class functions]].
 
=={{header|Julia}}==
{{works with|Julia|0.6}}
 
In Julia, like Python and R, functions can be treated as like as other Types.
 
<lang julia>x, xi = 2.0, 0.5
y, yi = 4.0, 0.25
z, zi = x + y, 1.0 / ( x + y )
 
multiplier = (n1, n2) -> (m) -> n1 * n2 * m
 
numlist = [x , y, z]
numlisti = [xi, yi, zi]
 
@show collect(multiplier(n, invn)(0.5) for (n, invn) in zip(numlist, numlisti))</lang>
 
{{out}}
<pre>collect(((multiplier(n, invn))(0.5) for (n, invn) = zip(numlist, numlisti))) = [0.5, 0.5, 0.5]</pre>
 
=={{header|Kotlin}}==
Anonymous user