7 ms·
I'm more of a fan of the zip/cycle approach: https://play.rust-lang.org/?gist=3fb51314d7df9249c9f774dde963873d&version=stable&backtrace=0 https://play.rust-lan
by vvanders 10y ago
I'm more of a fan of the zip/cycle approach:
https://play.rust-lang.org/?gist=3fb51314d7df9249c9f774dde963873d&version=stable&backtrace=0 https://play.rust-lang.org/?gist=3fb51314d7df9249c9f774dde96...
- iopq 10y agoMy approach works with arbitrary conditions, that's why it takes closures as arguments. So it's a little bit of a different requirement, I wanted something as general as possible.
- bradmwalker 10y agoPython https://gist.github.com/bradmwalker/b300f36e9427f729b458 https://gist.github.com/bradmwalker/b300f36e9427f729b458
- iopq 10y agoI like this approach. The only thing I would criticize is that it uses '' as a substitute for None. So something like fizzes, buzzes, empties = str_cycle('Fizz', 3), str_cycle('Buzz', 5), str_cycle('', 7) wouldn't work since it would print 7 instead of the empty string