zipWith
Zips two iterables and combines each pair through a function, in one step.
Lecture
zipWith is exactly zip followed by
map over the resulting pairs — in fact that's how it's
implemented in FxDart, as map((r) => f(r.$1, r.$2), zip(...)).
Reach for it when you don't actually want the intermediate
(A, B) record, just the combined result: multiplying two
parallel lists together, formatting a name and an age into one label,
and so on.
It stops at the shorter of the two inputs, same as zip, and
the async form zipWithAsync inherits zipAsync's
parallel-per-pair pulling. There's no Fx chain form for
zipWith — call the top-level function directly (or build it
yourself as .zip(other).map((r) => f(r.$1, r.$2))).
Demo 1 · Basics
Demo 2 · Async
Try it yourself
Exercise: use zipWith to compute the line total
(price * quantity) per pair.
zip — the plain-pairs version this builds on ·
zipWithIndex — zip against a running index ·
map