2 ms·
This is a fairly well known thing in all programming communities that matter, but it was good to see it pointed out once again. However, I would argue that the
by qwertyuiop924 10y ago
This is a fairly well known thing in all programming communities that matter, but it was good to see it pointed out once again.
However, I would argue that the classic guarded function using modulo would actually be clearer. It takes a moment to follow the logic of cycling up an infinite list, and modulo statments are far clearer and easier to understand to most people, I would say. In addition, it's easier to change than either of the above, and equally declarative: modulo is a declarative operation as is a guard: when x % 3 is zero, it IS fizz.
- frank_jaeger 10y agoWhat about when x is 15?
- qwertyuiop924 10y agoWhat about it? You make it a higher precedence guard.