First-class functions: Difference between revisions

Content added Content deleted
(Added standard functions as required by the task, one in second position of a sequence and one in first position which requires precising its type. Added a comment about this.)
(Added Arturo implementation)
Line 345: Line 345:
{{Out}}
{{Out}}
<lang AppleScript>{0.5, 0.5, 0.5}</lang>
<lang AppleScript>{0.5, 0.5, 0.5}</lang>

=={{header|Arturo}}==

<lang rebol>cube: function [x] -> x^3
croot: function [x] -> x^(1//3)

names: ["sin/asin", "cos/acos", "cube/croot"]
funclist: @[var 'sin, var 'cos, var 'cube]
invlist: @[var 'asin, var 'acos, var 'croot]

num: 0.5

loop 0..2 'f [
result: call funclist \ f @[num]
print [names \ f "=>" call invlist \ f @[result]]
]</lang>

{{out}}

<pre>sin/asin => 0.5
cos/acos => 0.4999999999999999
cube/croot => 0.5</pre>


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==