Phrase reversals: Difference between revisions

m
→‎{{header|AppleScript}}: Subheaders added. Typo correction in Idiomatic solution.
m (→‎{{header|AppleScript}}: Subheaders added. Typo correction in Idiomatic solution.)
Line 137:
 
=={{header|AppleScript}}==
===Functional===
 
AppleScript has a very small and patchy library of primitive functions. To accumulate a larger and more coherent library, which includes some higher order functions, we can try to overcome two architectural weaknesses: 1. Built-in functions have a different type from user functions, and 2. user functions are second class properties of (first class) script objects.
Line 271 ⟶ 272:
reversal phrase code rosetta"</pre>
 
----
===Idiomatic===
 
<lang applescript>set aString to "rosetta code phasephrase reversal"
Alternatively:
 
<lang applescript>set aString to "rosetta code phase reversal"
 
set astid to AppleScript's text item delimiters
 
set AppleScript's text item delimiters to ""
set phase1phrase1 to (reverse of characters of aString) as text
 
set AppleScript's text item delimiters to space
set phase2phrase2 to (reverse of words of phase1phrase1) as text
 
set phase3phrase3 to (reverse of words of aString) as text
 
set AppleScript's text item delimiters to linefeed
set output to {phase1phrase1, phase2phrase2, phase3phrase3} as text
 
set AppleScript's text item delimiters to astid
 
return output</lang>
 
{{out}}
{{output}}
<prelang applescript>"lasrever esahpesarhp edoc attesor
attesor edoc esahpesarhp lasrever
reversal phasephrase code rosetta"</prelang>
 
=={{header|AutoHotkey}}==
557

edits