newbie q

Will Stuyvesant hwlgw at
Thu Jan 13 07:56:49 EST 2005

I understand you want to do it in an applicative programming style?
Not recommended in general.  But here goes:

.# c.l.p. question:
.# "using map, lambda, reduce, filter and List Comprehensions [x for
.# x in []] just don't get how to add string to all elements of list"
.# A function that returns a function, taking a function as argument.
.def allapply(fn):
.    def f(seq): return map(fn, seq)
.    return f
.def add_string_to_element(stringval):
.    def f(x): return x + stringval
.    return f
.add_string_to_all = allapply(add_string_to_element('mystring'))
.print add_string_to_all(['d:', 'c:\windows\\','something/'])

this outputs:
['d:mystring', 'c:\\windows\\mystring', 'something/mystring']
look Ma, no for and no lambda!
        -- Will Stuyvesant

More information about the Python-list mailing list