Typo in S06?
S06.pod says (line 2698): : Ordinarily a top-level Perl "script" just evaluates its anonymous : mainline code and exits. During the mainline code, the program's : arguments are available in raw form from the C<@ARGS> array. At the end of : the mainline code, however, a C subroutine will be called with : whatever command-line arguments remain in C<@ARGS>. This call is : performed if and only if: Should these be C<@*ARGS> instead? Pm
Query re: duction and precedence.
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? -- Mark J. Reed <[EMAIL PROTECTED]>
[svn:perl6-synopsis] r14529 - doc/trunk/design/syn
Author: larry Date: Sat Mar 29 20:16:29 2008 New Revision: 14529 Modified: doc/trunk/design/syn/S06.pod Log: fossil noticed by pmichaud++ Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSat Mar 29 20:16:29 2008 @@ -2695,9 +2695,9 @@ Ordinarily a top-level Perl "script" just evaluates its anonymous mainline code and exits. During the mainline code, the program's -arguments are available in raw form from the C<@ARGS> array. At the end of +arguments are available in raw form from the C<@*ARGS> array. At the end of the mainline code, however, a C subroutine will be called with -whatever command-line arguments remain in C<@ARGS>. This call is +whatever command-line arguments remain in C<@*ARGS>. This call is performed if and only if: =over @@ -2755,7 +2755,7 @@ Common Unix command-line conventions are mapped onto the capture as follows: - On command line... $ARGS capture gets... + On command line... $*ARGS capture gets... -name :name -name=value:name
Re: Query re: duction and precedence.
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
Re: Query re: duction and precedence.
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]>