Catalan numbers/Pascal's triangle: Difference between revisions
→Python :: Composition of pure functions: docstring edit
m (→Composition of pure functions: Preamble edit) |
(→Python :: Composition of pure functions: docstring edit) |
||
Line 1,563:
derived from Pascal's triangle.'''
# diff :: [Int] -> Int
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 (
xs[0] - (xs[1] if 1 < len(xs) else 0)
|