String case: Difference between revisions

→‎{{header|AppleScript}}: Updated primitives, and simplified test, replacing map with `ap` <*>
(→‎{{header|AppleScript}}: Updated primitives)
(→‎{{header|AppleScript}}: Updated primitives, and simplified test, replacing map with `ap` <*>)
Line 333:
 
<lang applescript>use framework "Foundation"
 
 
-- TEST -----------------------------------------------------------------------
on run
ap({toLower, toTitle, toUpper}, mReturn(f)'s |λ|({"alphaBETA αβγδΕΖΗΘ"})
-- testCase :: Handler -> String
script testCase
on |λ|(f)
mReturn(f)'s |λ|("alphaBETA αβγδΕΖΗΘ")
end |λ|
end script
--> {"alphabeta αβγδεζηθ", "Alphabeta Αβγδεζηθ", "ALPHABETA ΑΒΓΔΕΖΗΘ"}
map(testCase, {toUpper, toLower, toTitle})
end run
Line 373 ⟶ 367:
end toUpper
 
-- mapA ::list (aof ->functions b)applied ->to [a] ->list of [b]arguments
-- (<*> | ap) :: [(a -> b)] -> [a] -> [b]
on mapap(ffs, xs)
tell mReturn(f)
set {intFs, intXs} to set{length lngof tofs, length of xs}
set lst to {}
repeat with i from 1 to lngintFs
tell set end of lst to |λ|mReturn(item i of xs, i, xsfs)
end repeat with j from 1 to intXs
set end of lst to |λ|(contents of (item j of xs))
return lst
end tellrepeat
end maptell
end |λ|repeat
return lst
end ap
 
-- Lift 2nd class handler function into 1st class script wrapper
Line 397 ⟶ 394:
end mReturn</lang>
{{Out}}
<lang AppleScript>{"ALPHABETAalphabeta ΑΒΓΔΕΖΗΘαβγδεζηθ", "alphabetaAlphabeta αβγδεζηθΑβγδεζηθ", "AlphabetaALPHABETA ΑβγδεζηθΑΒΓΔΕΖΗΘ"}</lang>
 
=={{header|Arbre}}==
9,659

edits