Factors of an integer: Difference between revisions

m
→‎{{header|AppleScript}}: (updated primitives)
(→‎{{Header|Haskell}}: mention and link to factorise from arithmoi)
m (→‎{{header|AppleScript}}: (updated primitives))
Line 298:
 
-- GENERIC LIBRARY FUNCTIONS
 
-- 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
 
-- 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 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 repeattell
end map
 
-- range :: Int -> Int -> [Int]
on range(m, n)
setif dn to< 1m then
if n < m then set d to -1
else
set d to 1
end if
set lst to {}
repeat with i from m to n by d
9,655

edits