3 ms·
But there is conditional logic "hidden" in lambda mapping. You want it without ANY conditional logic try this (python3): [str(n)*(n%3!=0)*(n%5!=0) + 'Fizz'*(n
by uuidgen 6y ago
But there is conditional logic "hidden" in lambda mapping.
You want it without ANY conditional logic try this
(python3):
[str(n)*(n%3!=0)*(n%5!=0) + 'Fizz'*(n%3==0) + 'Buzz'*(n%5==0) for n in range(1,101)]
- chongli 6y agoThere’s tons of hidden conditional logic in the Python string multiplication operator. It’s implemented via the C function unicode_repeat which handles all the conditional logic.
- uuidgen 6y agoIf you're talking about assembly then every single statement in python will involve hidden conditions. I was talking about the idea behind the code - that map is a pythonic shorthand for a bunch of if-then statements, it still expresses conditionals. While using string multiplication doesn't.