Permutations: Difference between revisions
→{{header|AppleScript}}: Directly defined delete,and concatMap, dropped foldl
(→JS ES6: (defining delete directly, rather than in terms of deleteBy)) |
(→{{header|AppleScript}}: Directly defined delete,and concatMap, dropped foldl) |
||
Line 440:
{{trans|JavaScript}}
(Functional
<lang AppleScript>-- permutations :: [a] -> [[a]]
Line 470:
end run
Line 477 ⟶ 476:
-- concatMap :: (a -> [b]) -> [a] -> [b]
on concatMap(f, xs)
set lng to length
tell
end script▼
end repeat
end concatMap
Line 497:
end tell
end map
▲ set v to lambda(v, item i of xs, i, xs)
▲ return v
-- delete :: a -> [a] -> [a]
on |delete|(x, xs)
if length of xs > 0 then
set {h, t} to uncons(xs)
if
t
else
{h} &
end if
else
{}
end if
end
-- uncons :: [a] -> Maybe (a, [a])
|