Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Zipping (computer science)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Language comparison== List of languages by support of zip: {| class="wikitable" |+ Zip in various languages |- ! scope="col" | Language ! scope="col" | Zip ! scope="col" | Zip 3 lists ! scope="col" | Zip ''n'' lists ! scope="col" | Notes |- ! scope="row" | [[Chapel (programming language)|Chapel]] | {{mono|zip (''iter1'' ''iter2'')}} | {{mono|zip (''iter1'' ''iter2'' ''iter3'')}} | {{mono|zip (''iter1'' ... ''itern'')}} | The shape of each iterator, the rank and the extents in each dimension, must be identical.<ref>{{cite web |url=https://chapel-lang.org/docs/language/spec/statements.html#zipper-iteration |title = Statements β Chapel Documentation 1.25}}</ref> |- ! scope="row" | [[Clojure]] | {{mono|(map list ''list1'' ''list2'')}}<br/>{{mono|(map vector ''list1'' ''list2'')}} | {{mono|(map list ''list1'' ''list2'' ''list3'')}}<br/>{{mono|(map vector ''list1'' ''list2'' ''list3'')}} | {{mono|(map list ''list1'' β¦ ''listn'')}}<br/>{{mono|(map vector ''list1'' β¦ ''listn'')}} | Stops after the length of the shortest list. |- ! scope="row" | [[Common Lisp]] | {{codett|2=lisp|(mapcar #'list list1 list2)}} | {{codett|2=lisp|(mapcar #'list list1 list2 list3)}} | {{codett|2=lisp|(mapcar #'list list1 ... listn)}} | Stops after the length of the shortest list. |- ! scope="row" | [[D (programming language)|D]] | {{mono|zip(''range1'', ''range2'')}}<br/>{{mono|''range1''.zip(''range2'')}} | {{mono|zip(''range1'', ''range2'',''range3'')}}<br/>{{mono|''range1''.zip(range2, range3)}} | {{mono|zip(''range1'', β¦, ''rangeN'')}}<br/>{{mono|''range1''.zip(β¦, rangeN)}} | The stopping policy defaults to shortest and can be optionally provided as shortest, longest, or requiring the same length.<ref>{{cite web |url=http://dlang.org/phobos/std_range.html#zip |title = std.range - D Programming Language}}</ref> The second form is an example of [[UFCS]]. |- ! scope="row" | [[F Sharp (programming language)|F#]] | {{mono|List.zip ''list1'' ''list2''}}<br/>{{mono|Seq.zip ''source1'' ''source2''}}<br/>{{mono|Array.zip ''array1'' ''array2''}} | {{mono|List.zip3 ''list1'' ''list2'' ''list3''}}<br/>{{mono|Seq.zip3 ''source1'' ''source2'' ''source3''}}<br/>{{mono|Array.zip3 ''array1'' ''array2'' ''array3''}} | | |- ! scope="row" | [[Haskell (programming language)|Haskell]] | {{mono|zip ''list1'' ''list2''}} | {{mono|zip3 ''list1'' ''list2'' ''list3''}} | {{mono|zip''n'' ''list1'' β¦ ''listn''}} | {{mono|zipn}} for ''n'' > 3 is available in the module ''Data.List''. Stops after the shortest list ends. |- ! scope="row" | [[Python (programming language)|Python]] | {{mono|zip(''list1'', ''list2'')}} | {{mono|zip(''list1'', ''list2'', ''list3'')}} | {{mono|zip(''list1'', β¦, ''listn'')}} | {{mono|''zip()''}} and {{mono|''map()''}} (3.x) stops after the shortest list ends, whereas {{mono|''map()''}} (2.x) and {{mono|''itertools.zip_longest()''}} (3.x) extends the shorter lists with {{mono|''None''}} items |- ! scope="row" | [[Ruby (programming language)|Ruby]] | {{mono|''list1''.zip(''list2'')}} | {{mono|''list1''.zip(''list2'', ''list3'')}} | {{mono|''list1''.zip(''list1'', .., ''listn'')}} | When the list being executed upon (list1) is shorter than the lists being zipped the resulting list is the length of list1. If list1 is longer nil values are used to fill the missing values<ref>{{Cite web|url=https://docs.ruby-lang.org/en/master/Array.html#method-i-zip|title = Class: Array}}</ref> |- ! scope="row" | [[Scala (programming language)|Scala]] | {{mono|''list1''.zip(''list2'')}} | | | If one of the two collections is longer than the other, its remaining elements are ignored.<ref>{{cite web |url=https://www.scala-lang.org/api/current/scala/collection/IterableOps.html#zip[B](that:scala.collection.IterableOnce[B]):CC[(A@scala.annotation.unchecked.uncheckedVariance,B) |title=IterableOps |date= |website=scala-lang.org}}</ref> |} {| class="wikitable" |+ Unzip in various languages |- ! scope="col" | Language ! scope="col" | Unzip ! scope="col" | Unzip 3 tuples ! scope="col" | Unzip ''n'' tuples ! scope="col" | Notes |- ! scope="row" | [[Clojure]] | {{mono|(apply map vector ''ziplist'')}} | {{mono|(apply map vector ''ziplist'')}} | {{mono|(apply map vector ''ziplist'')}} | |- ! scope="row" | [[Common Lisp]] | {{codett|2=lisp|(apply #'mapcar #'list ziplist)}} | {{codett|2=lisp|(apply #'mapcar #'list ziplist)}} | {{codett|2=lisp|(apply #'mapcar #'list ziplist)}} | |- ! scope="row" | [[F Sharp (programming language)|F#]] | {{mono|List.unzip ''list1'' ''list2''}}<br/>{{mono|Seq.unzip ''source1'' ''source2''}}<br/>{{mono|Array.unzip ''array1'' ''array2''}} | {{mono|List.unzip3 ''list1'' ''list2'' ''list3''}}<br/>{{mono|Seq.unzip3 ''source1'' ''source2'' ''source3''}}<br/>{{mono|Array.unzip3 ''array1'' ''array2'' ''array3''}} | | |- ! scope="row" | [[Haskell (programming language)|Haskell]] | {{mono|unzip ''ziplist''}} | {{mono|unzip3 ''ziplist''}} | {{mono|unzip''n'' ''ziplist''}} | {{mono|unzipn}} for ''n'' > 3 is available in the module {{mono|''Data.List''.}} |- ! scope="row" | [[Python (programming language)|Python]] | {{mono|zip(*''zipvlist'')}} | {{mono|zip(*''zipvlist'')}} | {{mono|zip(*''zipvlist'')}} | |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)