Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#877·lo

Add a zip helper that stops at the shortest input

Author: apstndbCreated May 3, 2026Updated Sep 27, 2026
Labelsbreaking change

it.ZipBy2 currently pads missing values with zero values when inputs have different lengths.

In some cases, a helper that stops as soon as either input is exhausted is safer and more useful. This matches the common “zip shortest” behavior used in many other languages and iterator libraries.

Proposal

Add a new helper in lo/it with “shortest input wins” semantics, for example:

  • ZipShortestBy2
  • ZipShortBy2
  • ZipBy2Shortest

Expected behavior

The helper should yield values only while both input sequences still have elements, and stop when either side ends.

This would help avoid subtle bugs caused by zero-value padding when input lengths differ.

Source: samber/lo

View original on GitHubView discussion on GitHub