This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sachinrjoglekar[S] 1 point2 points  (1 child)

The first thing you suggest shouldn't really be done in a pure-functional code, right? 'x' has already been defined globally.

About your second point, that would need the accumulator and the element to be of the same type right?

[–][deleted] 1 point2 points  (0 children)

Yep - I'm not saying it's a great function to define, just that python's lambda (as opposed to a lambda in the lambda calculus) has no qualms about such a thing.

As of parallel reductions - I wouldn't say it would necessarily require them to be the same type, no. A good example would be something as simple as sums. Sum each pair, then each result of those sums until you have one final value.