RosettaCodeData/Task/Higher-order-functions/AppleScript/higher-order-functions-1.applescript

26 lines
656 B
AppleScript
Raw Permalink Normal View History

2015-02-20 00:35:01 -05:00
-- This handler takes a script object (singer)
-- with another handler (call).
on sing about topic by singer
2016-12-05 22:15:40 +01:00
call of singer for "Of " & topic & " I sing"
2015-02-20 00:35:01 -05:00
end sing
-- Define a handler in a script object,
-- then pass the script object.
script cellos
2016-12-05 22:15:40 +01:00
on call for what
say what using "Cellos"
end call
2015-02-20 00:35:01 -05:00
end script
sing about "functional programming" by cellos
-- Pass a different handler. This one is a closure
-- that uses a variable (voice) from its context.
on hire for voice
2016-12-05 22:15:40 +01:00
script
on call for what
say what using voice
end call
end script
2015-02-20 00:35:01 -05:00
end hire
sing about "closures" by (hire for "Pipe Organ")