Maximum triangle path sum: Difference between revisions

m
→‎{{header|Haskell}}: Defined the null case.
(→‎{{header|Haskell}}: Added a ZipList variant)
m (→‎{{header|Haskell}}: Defined the null case.)
Line 1,886:
 
<syntaxhighlight lang="haskell">import Control.Applicative (ZipList (ZipList, getZipList))
 
 
---------------- MAXIMUM TRIANGLE PATH SUM ---------------
 
maxPathSum :: [[Int]] -> Int
maxPathSum [] = 0
maxPathSum triangleRows =
head
( foldr1
( \xs ->
Line 1,908 ⟶ 1,910:
triangleRows
)
 
--------------------------- TEST -------------------------
9,655

edits