Zip
Zip[list1, list2]
Combines two lists into a single list of pairs. The resulting list has the same length as the shorter input list; extra elements from the longer list are ignored.
- Returns a
Listof two‑elementLists.
Zip[{ 1, 2, 3 }, { "a", "b" }]; (* => {{1, "a"}, {2, "b"}} *)
Zip[{ 1 }, { 2, 3, 4 }]; (* => {{1, 2}} *)
ZipWith
ZipWith[list1, list2, fun]
Combines corresponding elements from list1 and list2 by applying the binary function fun.
The resulting list has the same length as the shorter input list.
funmust accept two arguments.- Returns a
Listcontaining the results.
ZipWith[{ 1, 2, 3 }, { 4, 5, 6 }, Add]; (* => {5, 7, 9} *)
ZipWith[{ "a", "b" }, { "c", "d" }, Concat]; (* => {"ac", "bd"} *)