Sierpinski triangle: Difference between revisions
Undo revision 294290 by Hout (talk)
m (→{{header|Python}}: (Added docstrings)) |
|||
Line 3,216:
and fold/reduce, wrapped as concatMap, can provide the list comprehensions too:
<lang python>
from operator import (add)▼
▲from operator import add
# sierpinski :: Int -> String
def sierpinski(n):
def go(xs, i):
s = ' ' * (2 ** i)
Line 3,235 ⟶ 3,232:
# concatMap :: (a -> [b]) -> [a] -> [b]
def concatMap(f):
return lambda xs: (
reduce(add, map(f, xs), [])
|