Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library
← Back to context

Comment by Cyphase

2 years ago

Side note, you don't need `if bar_vec != []`. Trying to loop over an empty iterable (e.g. a list) just doesn't loop, since there's nothing there.

Also, another way to write this (which results in a flattened list) is:

  [foo(x) for bar_vec in bar_mat for y in bar_vec if baz(y) for x in y]

0 comments

Cyphase

Reply

No comments yet

Contribute on Hacker News ↗

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities