Apply a callback to an array: Difference between revisions
Content added Content deleted
(Added Bracmat example) |
(→{{header|AppleScript}}: Add) |
||
Line 141: | Line 141: | ||
array[ +4] = +16 |
array[ +4] = +16 |
||
</pre> |
</pre> |
||
=={{header|AppleScript}}== |
|||
<lang applescript>on callback for arg |
|||
-- Returns a string like "arc has 3 letters" |
|||
arg & " has " & (count arg) & " letters" |
|||
end callback |
|||
set alist to {"arc", "be", "circle"} |
|||
repeat with aref in alist |
|||
-- Passes a reference to some item in alist |
|||
-- to callback, then speaks the return value. |
|||
say (callback for aref) |
|||
end repeat</lang> |
|||
If the callback would <code>set arg's contents to "something"</code>, then <code>alist</code> would be mutated. |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |