Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
acd22f91
Commit
acd22f91
authored
Aug 14, 2003
by
Neil Schemenauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't introduce map(None, ...) in the tutorial. In practice, zip() is
usually preferred.
parent
7f2d4cb0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
9 deletions
+4
-9
Doc/tut/tut.tex
Doc/tut/tut.tex
+4
-9
No files found.
Doc/tut/tut.tex
View file @
acd22f91
...
...
@@ -1836,19 +1836,14 @@ cubes:
More than one sequence may be passed; the function must then have as
many arguments as there are sequences and is called with the
corresponding item from each sequence
(
or
\code
{
None
}
if some sequence
is shorter than another
)
. If
\code
{
None
}
is passed for the function,
a function returning its argument
(
s
)
is substituted.
Combining these two special cases, we see that
\samp
{
map
(
None,
\var
{
list
1
}
,
\var
{
list
2
}
)
}
is a convenient way of
turning a pair of lists into a list of pairs. For example:
is shorter than another
)
. For example:
\begin
{
verbatim
}
>>> seq
=
range
(
8
)
>>> def
square
(
x
)
: return x
*
x
>>> def
add
(
x, y
)
: return x
+
y
...
>>> map
(
None, seq, map
(
square, seq
)
)
[
(
0
,
0
)
,
(
1
,
1
)
,
(
2
,
4
)
,
(
3
,
9
)
,
(
4
,
16
)
,
(
5
,
25
)
,
(
6
,
36
)
,
(
7
,
49
)
]
>>> map
(
add, seq, seq
)
[
0
,
2
,
4
,
6
,
8
,
10
,
12
,
14
]
\end
{
verbatim
}
\samp
{
reduce
(
\var
{
func
}
,
\var
{
sequence
}
)
}
returns a single value
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment