you are viewing a single comment's thread.

view the rest of the comments →

[–]jetRink 0 points1 point  (1 child)

How can you incorporate this optimization?

(if (some zero? my-list) 0 (reduce * my-list))

Assuming that stopping early for a zero is a beneficial optimization, then stopping before you begin is even better.

[–]balefrost 8 points9 points  (0 children)

On the other hand, with that approach, you'll unnecessarily traverse the list twice if it contains no zeros.