Perfect numbers: Difference between revisions

m
→‎{{header|AppleScript}}: updated primitives
(Removed extraneous line)
m (→‎{{header|AppleScript}}: updated primitives)
Line 271:
-- filter :: (a -> Bool) -> [a] -> [a]
on filter(f, xs)
set mf totell mReturn(f)
set lst to {}
set lstlng to {}length of xs
repeat with i from 1 to lng
set lng to length of xs
repeat with i from 1 set v to lngitem i of xs
set v to item if lambda(v, i, xs) then set end of xslst to v
ifend mf's lambda(v, i, xs) thenrepeat
set end ofreturn lst to v
end iftell
end repeat
return lst
end filter
 
-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
set mf to mReturn(f)
set lng to length of xs
set lst to {}
repeat with i from 1 to lng
set end of lst to mf's lambda(item i of xs, i, xs)
end repeat
return lst
end map
 
-- foldl :: (a -> b -> a) -> a -> [b] -> a
on foldl(f, startValue, xs)
set mf totell mReturn(f)
set v to startValue
set vlng to startValuelength of xs
repeat with i from 1 to lng
set lng to length of xs
set v to mf's lambda(v, item i of xs, i, xs)
repeat with i from 1 to lng
end repeat
set v to mf's lambda(v, item i of xs, i, xs)
end repeat return v
returnend vtell
end foldl
 
-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
set mf totell mReturn(f)
set lng to length of xs
set lst to {}
repeat with i from 1 to lng
set end of lst to mf's lambda(item i of xs, i, xs)
end repeat
return lst
end tell
end map
 
-- range :: Int -> Int -> [Int]
9,655

edits