Floyd's triangle: Difference between revisions

m
→‎{{header|Python}}: (Slight simplification of the type)
(→‎{{header|Haskell}}: Alternatively, defining just the relationship between successive terms:)
m (→‎{{header|Python}}: (Slight simplification of the type))
Line 3,546:
 
 
# floyd :: [[Int]] -> [[Int]]
def floyd(xs):
n = succ(len(xs))
return [[1]] if n < 2 else xs + [(
enumFromTo(succ(n * pred(n) // 2))(
n * succ(n) // 2
)
])
 
 
# floydN :: Int -> [[Int]]
def floydN(n):
return take(succ(n))(iterate(floyd)([1]))[n]
 
 
9,655

edits