First-class functions: Difference between revisions

m
(Added Quackery.)
imported>Arakov
(One intermediate revision by one other user not shown)
Line 1,135:
 
=={{header|Elena}}==
ELENA 56.0x :
<syntaxhighlight lang="elena">import system'routines;
import system'math;
Line 1,153:
fs.zipBy(gs, (f,g => 0.5r.compose(f,g)))
.forEach:(printingLn)
}</syntaxhighlight>
{{out}}
Line 3,241:
=={{header|Wren}}==
In Wren, there is a distinction between functions and methods. Essentially, the former are independent objects which can do all the things required of 'first class functions' and the latter are subroutines which are tied to a particular class. As sin, cos etc. are instance methods of the Num class, we need to wrap them in functions to complete this task.
<syntaxhighlight lang="ecmascriptwren">var compose = Fn.new { |f, g| Fn.new { |x| f.call(g.call(x)) } }
 
var A = [
Anonymous user