Aside: there is no built-in for "lambda x, f: f(x)" somewhere, is there?
On Fri, Feb 12, 2010 at 11:54 AM, Vitor Bosshard <algorias@gmail.com> wrote:I assume you mean that the following lines would be equivalent:starreduce(f, iterable, initial)reduce(lambda x,y: f(x, *y), iterable, initial)Precisely.It seems like a very narrow use-case [...]Agreed, that example is. I also use it for high-level functional stuff - something like Haskell's monads or Java's "chain-of-responsibility". Like:output = reduce(lambda x, f: f(x), chain_of_processors, input)So, given a list [f,g,h], this would be h(g(f(input))). The star-case is when input is a n-touple, and each function works on `n' arguments. But now that I wrote it out without a for loop, it's obviously trivial to add the star in the right place. My mistake! Thanks for helping me catch it :)Cheers,Andrey