# A Q concerning map (a comparison to Maple V)

Peter Schneider-Kamp peter at schneider-kamp.de
Sat Dec 23 06:06:29 EST 2000

```Franz GEIGER schrieb:
>
> map(replace, ["abc", "cde"], "c", "C");
> instead of having to create a lambda function.
> Wouldn't it make sense to have that in Python too? Do there come
> more such opportunities into your mind?

If I get you right you intend this to mean:

map(replace, ["abc", "cde"], ["c"]*2, ["C"]*2)

So basically your proposal is to reuse map parameters
which are no sequences in every iteration over the
parameters who are, s.t.

map(f, a_1, .., a_n, b_1, .., b_m)

for f being a (m+n)-ary function, a_1 to a_n being sequence
parameters and b_1 to b_m non-sequence parameters would yield

maxlen = max(map(len,[a_1, .., a_n]))
map(f, a_1, .., a_n, [b_1]*maxlen, .., [b_m]*maxlen)

But how would you decide if "abc" is a sequence parameter
or not? To keep your example, what would

map(replace, ["abc", "cde"], "cd", "CD")

mean? At the moment this gives you:

["abC", "cDe"]

whereas with you proposal this would give you:

["abc", "CDe"]

Excuse me if I misinterpreted your proposal, but if the
above is what you mean, I think this a Bad Idea(tm).

merry-xmas-shopping-ly y'rs
Peter

```