Pascal's triangle: Difference between revisions
Content added Content deleted
(→Functional Python: pylinted for Python 3, tidied.) |
m (→Functional Pascal: Updated preamble) |
||
Line 4,111: | Line 4,111: | ||
===Functional=== |
===Functional=== |
||
The itertools module yields a simple functional definition of '''scanl''' in terms of '''accumulate''' and ''' |
The itertools module yields a simple functional definition of '''scanl''' in terms of '''accumulate''', and '''zipWith''' can be defined in terms either of '''itertools.starmap''', or the base '''map'''. |
||
With a scanl and a zipWith to hand, we can derive both finite and non-finite lists of pascal rows from a |
With a scanl and a zipWith to hand, we can derive both finite and non-finite lists of pascal rows from a simple '''nextPascal''' step function: |
||
{{Works with|Python|3.7}} |
{{Works with|Python|3.7}} |