September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -2,23 +2,27 @@
-- permutations :: [a] -> [[a]]
on permutations(xs)
script firstElement
on |λ|(x)
script tailElements
on |λ|(ys)
{{x} & ys}
script go
on |λ|(xs)
script h
on |λ|(x)
script ts
on |λ|(ys)
{{x} & ys}
end |λ|
end script
concatMap(ts, go's |λ|(|delete|(x, xs)))
end |λ|
end script
concatMap(tailElements, permutations(|delete|(x, xs)))
if {} xs then
concatMap(h, xs)
else
{{}}
end if
end |λ|
end script
if length of xs > 0 then
concatMap(firstElement, xs)
else
{{}}
end if
go's |λ|(xs)
end permutations
@ -58,17 +62,6 @@ on |delete|(x, xs)
end if
end |delete|
-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
tell mReturn(f)
set lng to length of xs
set lst to {}
repeat with i from 1 to lng
set end of lst to |λ|(item i of xs, i, xs)
end repeat
return lst
end tell
end map
-- Lift 2nd class handler function into 1st class script wrapper
-- mReturn :: Handler -> Script