Author: larry Date: Sun Jun 3 17:23:15 2007 New Revision: 14415 Modified: doc/trunk/design/syn/S03.pod doc/trunk/design/syn/S04.pod doc/trunk/design/syn/S06.pod
Log: typo from Aaron Crane++ s/cat/list/ for flattening captures in order cat() now only produces pseudo-strings even in list context Modified: doc/trunk/design/syn/S03.pod ============================================================================== --- doc/trunk/design/syn/S03.pod (original) +++ doc/trunk/design/syn/S03.pod Sun Jun 3 17:23:15 2007 @@ -610,7 +610,7 @@ $string x $count Evaluates the left argument in string context, replicates the resulting -string value the number of time specified by the right argument and +string value the number of times specified by the right argument and returns the result as a single concatenated string regardless of context. If the count is less than 1, returns the null string. @@ -625,7 +625,7 @@ @list xx $count Evaluates the left argument in list context, replicates the resulting -C<Capture> value the number of time specified by the right argument and +C<Capture> value the number of times specified by the right argument and returns the result in a context dependent fashion. If the operator is being evaluated in ordinary list context, the operator returns a flattened list. In slice (C<@@>) context, the operator converts each C<Capture> @@ -3554,15 +3554,12 @@ ... } -To read arrays serially rather than in parallel, use C<cat(@x;@y)>. -This wins a "useless use of cat award" in this case since you could +To read arrays serially rather than in parallel, use C<list(@x;@y)>. +This wins a "useless use of list award" in this case since you could always just write C<(@x,@y)> to mean the same thing. But sometimes it's nice to be explicit about that: - @foo := [[1,2,3],[4,5,6]]; say cat([;] @foo); # 1,2,3,4,5,6 - -(The C<cat> function is not entirely useless; it also provides stringy -semantics in string context.) + @foo := [[1,2,3],[4,5,6]]; say list([;] @foo); # 1,2,3,4,5,6 =head1 Minimal whitespace DWIMmery Modified: doc/trunk/design/syn/S04.pod ============================================================================== --- doc/trunk/design/syn/S04.pod (original) +++ doc/trunk/design/syn/S04.pod Sun Jun 3 17:23:15 2007 @@ -391,14 +391,11 @@ for %hash.kv -> $key, $value { print "$key => $value\n" } -To process two arrays in parallel, use the C<each> function: +To process two arrays in parallel use the C<zip> function to generate a +list that can be bound to the corresponding number of parameters: - for each(@a;@b) -> $a, $b { print "[$a, $b]\n" } - -or use the C<zip> function to generate a list of C<Seq> objects that each can -be bound to multiple arguments enclosed in square brackets: - - for zip(@a;@b) -> [$a, $b] { print "[$a, $b]\n" } + for zip(@a;@b) -> $a, $b { print "[$a, $b]\n" } + for @a Z @b -> $a, $b { print "[$a, $b]\n" } # same thing The list is evaluated lazily by default, so instead of using a C<while> to read a file a line at a time as you would in PerlĀ 5: Modified: doc/trunk/design/syn/S06.pod ============================================================================== --- doc/trunk/design/syn/S06.pod (original) +++ doc/trunk/design/syn/S06.pod Sun Jun 3 17:23:15 2007 @@ -1060,16 +1060,16 @@ Various contexts may or may not be expecting multi-dimensional slices or feeds. By default, ordinary arrays are flattened, that is, they -have "cat" semantics. If you say +have "list" semantics. If you say (0..2; 'a'..'c') ==> my @tmp; for @tmp { .say } then you get 0,1,2,'a','b','c'. If you have a multidim array, you -can ask for cat semantics explicitly with cat(): +can ask for list semantics explicitly with list(): (0..2; 'a'..'c') ==> my @@tmp; - for @@tmp.cat { .say } + for @@tmp.list { .say } As we saw earlier, "zip" produces an interleaved result by taking one element from each list in turn, so