|
|
|
|
|
by xoudini
1900 days ago
|
|
Here's a (perhaps "unnecessarily clever") Python 3 version I wrote a while back, for some reason: import functools
def fizzbuzz(n):
if not n % 3: yield (r := "fizz")
if not n % 5: yield (r := "buzz")
if not "r" in locals(): yield n
compose = lambda f, g: lambda *args: f(g(*args))
functions = "".join, functools.partial(map, str), fizzbuzz
transform = functools.reduce(compose, functions)
print("\n".join(map(transform, range(1, 100))))
|
|