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 lst to {}▼
set
repeat with i from 1 to lng▼
set lng to length of xs▼
end repeat▼
return lst▼
end filter
-- map :: (a -> b) -> [a] -> [b]▼
on map(f, xs)▼
set mf to mReturn(f)▼
▲ 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▼
end map▼
-- foldl :: (a -> b -> a) -> a -> [b] -> a
on foldl(f, startValue, xs)
set v to startValue
set
repeat with i from 1 to lng▼
▲ repeat with i from 1 to lng
▲ end repeat
▲ set v to mf's lambda(v, item i of xs, i, xs)
end foldl
▲-- map :: (a -> b) -> [a] -> [b]
▲on map(f, xs)
▲ set lng to length of xs
set lst to {}
repeat with i from 1 to lng
▲ end repeat
▲ return lst
end tell
▲end map
-- range :: Int -> Int -> [Int]
|