Catalan numbers/Pascal's triangle: Difference between revisions

Content added Content deleted
Line 1,563: Line 1,563:
derived from Pascal's triangle.'''
derived from Pascal's triangle.'''


# diff :: [Int] -> Int
def diff(xs):
def diff(xs):
'''Difference between the first two items in the list,
if its length is more than one.
Otherwise, the first (only) item in the list.'''
return (
return (
xs[0] - (xs[1] if 1 < len(xs) else 0)
xs[0] - (xs[1] if 1 < len(xs) else 0)