List comprehensions: Difference between revisions

→‎{{header|AppleScript}}: Updated concatMap
m (→‎{{header|REXX}}: addec/changed some comments and whitespace, changed indentation of some output.)
(→‎{{header|AppleScript}}: Updated concatMap)
Line 228:
-- (>>=) :: Monad m => m a -> (a -> m b) -> m b
on |>>=|(xs, f)
concat(mapconcatMap(f, xs))
end |>>=|
 
-- concatconcatMap :: [[(a]] -> [ab]) |-> [Stringa] -> String[b]
on concatconcatMap(f, xs)
scriptset appendacc to {}
tell on |λ|mReturn(a, bf)
repeat with x in a & bxs
end set acc to acc & |λ|(contents of x)
end scriptrepeat
end tell
return acc
if length of xs > 0 and class of (item 1 of xs) is string then
end concatMap
set empty to ""
else
set empty to {}
end if
foldl(append, empty, xs)
end concat
 
-- enumFromTo :: Int -> Int -> [Int]
9,659

edits