Jump to content

Higher-order functions: Difference between revisions

Line 289:
filtered(lstRange, isEven)
--> {0, 2, 4, 6, 8, 10}</lang>
 
As a footnote on lifting 2nd class AppleScript handlers into first class objects for use with higher order functions, the role of '''mReturn''' or '''mInject''' can be inlined in such functions as followed, if preferred:
 
<lang AppleScript>-- [a] -> (a -> b) -> [b]
on map(xs, f)
script mf
property call : f
end script
set lst to {}
set lng to length of xs
repeat with i from 1 to lng
set end of lst to mf's call(item i of xs, i, xs)
end repeat
return lst
end map</lang>
 
=={{header|ATS}}==
9,659

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.