Greatest subsequential sum: Difference between revisions

m
→‎{{header|AppleScript}}: Updated primitives – max and gt
m (→‎{{header|AppleScript}}: Updated primitives – max and gt)
Line 126:
end tell
end foldl
 
-- gt :: Ord a => a -> a -> Bool
on gt(x, y)
set c to class of x
if listrecord is c or recordlist is c then
set {a, b} to {fst(x), > fst(y)}
else
if a > b thenx > y
end if
end gt
 
-- fst :: (a, b) -> a
Line 150 ⟶ 160:
-- max :: Ord a => a -> a -> a
on max(x, y)
setif cgt(x, toy) class of xthen
if list is c or record is c then
set {a, b} to {fst(x), fst(y)}
else
set {a, b} to {x, y}
end if
if a > b then
x
else
9,655

edits