Hacker News new | past | comments | ask | show | jobs | submit login

I'm more of a fan of the zip/cycle approach:

https://play.rust-lang.org/?gist=3fb51314d7df9249c9f774dde96...




My 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.



I 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




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: