You anticipated me. So, is there a core method for
foldl/foldr/inject/reduce, or do you have to roll your own as in p5?



On 3/29/08, Larry Wall <[EMAIL PROTECTED]> wrote:
> On Sat, Mar 29, 2008 at 10:18:53PM -0400, Mark J. Reed wrote:
> : In general, is
> :
> : [op] (p1,p2,p3,p4...)
> :
> : expected to return the same result as
> :
> : p1 op p2 op p3 op p4...
> :
> : including precedence considerations?
> :
> : That is, should
> :
> : [**](2,3,4)
> :
> : return 2^(3^4)=2^81, or (2^3)^4 = 4096?
>
> Yes, in fact the section on Reduction Operators uses exponentiation
> obliquely in one of its examples of something that should work
> right-to-left.  Admittedly it's not clearly stated there...
>
> But the basic idea is always that the reduction form should produce
> the same result as if you'd written it out with interspersed infixes.
> It's a linguistic construct, not a functional programming construct.
> It's not intended to be in the same league as foldl and foldr, and
> is only just slightly beyond a macro insofar as it can intersperse
> however many operators it needs to for an arbitrarily sized list.
> It's not making any attempt to deal with anonymous first-class
> functions though.  Call a real function for that. :)
>
> Larry
>

-- 
Sent from Gmail for mobile | mobile.google.com

Mark J. Reed <[EMAIL PROTECTED]>

Reply via email to