Reverse words in a string: Difference between revisions

Line 164:
-- String -> String
on reverseWords(str)
mfPipeLine({my unwords, my (_reverse, my (_words})'s call(str)))
end reverseWords
 
Line 222:
return lst
end map
 
-- Right to left composition of an arbitrary number
-- of unadorned AppleScript handlers into a method of a script object
on mfPipeLine(fs)
script mf
property hs : fs
on call(x)
set v to x
set lng to length of hs
repeat with i from lng to 1 by -1
set v to mReturn(item i of hs)'s call(v)
end repeat
return v
end call
end script
end mfPipeLine
 
-- lift 2nd class function into 1st class wrapper
Line 245 ⟶ 229:
property call : f
end script
end mReturn</lang>
</lang>
{{out}}
 
9,659

edits