Pascal's triangle: Difference between revisions

Content added Content deleted
m (→‎{{header|AppleScript}}: updated primitive)
Line 358: Line 358:
-- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
-- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
on zipWith(f, xs, ys)
on zipWith(f, xs, ys)
set lng to length of xs
set nx to length of xs
if lng is not length of ys then return missing value
set ny to length of ys
if nx < 1 or ny < 1 then
set mf to mReturn(f)
{}
set lst to {}
else
repeat with i from 1 to lng
set lng to cond(nx < ny, nx, ny)
set end of lst to mf's lambda(item i of xs, item i of ys)
set lst to {}
tell mReturn(f)
end repeat
repeat with i from 1 to lng
return lst
set end of lst to lambda(item i of xs, item i of ys)
end repeat
return lst
end tell
end if
end zipWith
end zipWith


-- cond :: Bool -> (a -> b) -> (a -> b) -> (a -> b)
on cond(bool, f, g)
if bool then
f
else
g
end if
end cond


-- intercalate :: Text -> [Text] -> Text
-- intercalate :: Text -> [Text] -> Text