r31054 -[S03] suggestions from dataweaver++

2010-06-02 Thread pugs-commits
Author: lwall
Date: 2010-06-02 20:19:54 +0200 (Wed, 02 Jun 2010)
New Revision: 31054

Modified:
   docs/Perl6/Spec/S03-operators.pod
Log:
[S03] suggestions from dataweaver++
more refinements to the description of the dwim semantics


Modified: docs/Perl6/Spec/S03-operators.pod
===
--- docs/Perl6/Spec/S03-operators.pod   2010-06-02 18:02:31 UTC (rev 31053)
+++ docs/Perl6/Spec/S03-operators.pod   2010-06-02 18:19:54 UTC (rev 31054)
@@ -4039,16 +4039,29 @@
 into correspondence.  If both sides are dwimmy, the short list will have be 
repeated
 as many times as necessary to make the appropriate number of elements.
 
-If only one side is dwimmy, then the list on that side only will be grown or
-truncated to fit the list on the non-dwimmy side.
+If only one side is dwimmy, then the list on that side only will be
+grown or truncated to fit the list on the non-dwimmy side.
 
+Regardless of whether the dwim is forced or emergent from the shapes
+of the arrays, once the side to dwim on has been chosen, the dwim
+semantics on the dwimmy side are always:
+
+(@dwimmyside xx *).batch(@otherside.elems)
+
+This produces a list the same length as the corresponding dimension
+on the other side.  The original operator is then recursively applied
+to each corresponding pair of elements, in case there are more dimensions
+to handle.
+
+Here are some examples:
+
 (1,2,3,4) »+« (1,2)   # always error
-(1,2,3,4) «+» (1,2)   # 2,4,4,6 rhs dwims to ((1,2) xx *).batch(4)
-(1,2,3)   «+» (1,2)   # 2,4,4   rhs dwims to ((1,2) xx *).batch(3)
-(1,2,3,4) «+« (1,2)   # 2,4 lhs dwims to (1,2,3,4).batch(2)
-(1,2,3,4) »+» (1,2)   # 2,4,4,6 rhs dwims to ((1,2) xx *).batch(4)
-(1,2,3)   »+» (1,2)   # 2,4,4,6 rhs dwims to ((1,2) xx *).batch(3)
-(1,2,3)   »+» 1   # 2,3,4   rhs dwims to (1 xx *).batch(3)
+(1,2,3,4) «+» (1,2)   # 2,4,4,6 rhs dwims to 1,2,1,2
+(1,2,3)   «+» (1,2)   # 2,4,4   rhs dwims to 1,2,1
+(1,2,3,4) «+« (1,2)   # 2,4 lhs dwims to 1,2
+(1,2,3,4) »+» (1,2)   # 2,4,4,6 rhs dwims to 1,2,1,2
+(1,2,3)   »+» (1,2)   # 2,4,4   rhs dwims to 1,2,1
+(1,2,3)   »+» 1   # 2,3,4   rhs dwims to 1,1,1
 
 Another way to look at it is that the dwimmy list's elements are
 indexed modulo its number of elements so as to produce as many or as



Re: r31054 -[S03] suggestions from dataweaver++

2010-06-02 Thread Jon Lang
pugs-comm...@feather.perl6.nl wrote:
 +Regardless of whether the dwim is forced or emergent from the shapes
 +of the arrays, once the side to dwim on has been chosen, the dwim
 +semantics on the dwimmy side are always:
 +
 +    (@dwimmyside xx *).batch(@otherside.elems)
 +
 +This produces a list the same length as the corresponding dimension
 +on the other side.  The original operator is then recursively applied
 +to each corresponding pair of elements, in case there are more dimensions
 +to handle.

Very useful; thank you.  One more request: could you provide a few
multidimensional examples?  For instance:

(1, 2, 3; 4, 5, 6) «+» (1, 2; 3, 4; 5, 6)

My gut instinct is that this would be equivalent to:

(1, 2, 3; 4, 5, 6; 1, 2, 3) «+» (1, 2; 3, 4; 5, 6) # lhs dwimmery
in the first dimension

...which in turn would be equivalent to:

(1, 2, 3; 4, 5, 6; 1, 2, 3) «+» (1, 2, 1; 3, 4, 3; 5, 6, 5) # rhs
dwimmery in the second dimension

Or:

(2, 4, 4; 7, 9, 9; 6, 8, 8)

But I'm not sure.  If I'm right, I'd like it confirmed; if I'm wrong,
I want to see what the right way to do it is.

-- 
Jonathan Dataweaver Lang


Re: r31054 -[S03] suggestions from dataweaver++

2010-06-02 Thread yary
And while we're at it with expanding examples, can we use string
concatenation instead of addition? It makes following what's happening
easier.

eg, +1 on that prior post.

-y