First-class functions: Difference between revisions

→‎{{header|Raku}}: The composition operator is built in raku
(Update Lang example: Use new operation parser syntax)
(→‎{{header|Raku}}: The composition operator is built in raku)
Line 2,603:
=={{header|Raku}}==
(formerly Perl 6)
Here we use the <tt>Z</tt> ("zipwith") metaoperator to zip the 𝐴 and 𝐵 lists with abuiltin user-definedcomposition compose functionoperator, expressed<tt>∘</tt> as(or an infix operator,just <tt>o</tt>). The <tt>.()</tt> construct invokes the function contained in the <tt>$_</tt> (current topic) variable.
<syntaxhighlight lang="raku" line>sub infix:<∘> (&𝑔, &𝑓) { -> \x { 𝑔 𝑓 x } }
 
<syntaxhighlight lang="raku" line>my \𝐴 = &sin, &cos, { $_ ** <3/1> }
my \𝐵 = &asin, &acos, { $_ ** <1/3> }
 
1,934

edits