Do you have real-world use cases for map's None fill-in feature?
tim.peters at gmail.com
Tue Jan 10 16:15:14 CET 2006
> I scanned the docs for Haskell, SML, and Perl and found that the norm
> for map() and zip() is to truncate to the shortest input or raise an
> exception for unequal input lengths.
> Also, I'm curious as to whether someone has seen a zip fill-in feature
> employed to good effect in some other programming language, perhaps
> LISP or somesuch?
FYI, Common Lisp's `pairlis` function requires that its first two
arguments be lists of the same length. It's a strain to compare to
Python's zip() though, as the _intended_ use of `pairlis` is to add
new pairs to a Lisp association list. For that reason, `pairlis`
accepts an optional third argument; if present, this should be an
association list, and pairs from zipping the first two arguments are
prepended to it. Also for this reason, the _order_ in which pairs are
taken from the first two arguments isn't defined(!).
For its intended special-purpose use, it wouldn't make sense to allow
arguments of different lengths.
More information about the Python-list