Re: numerics, roles, and naming

2010-03-15 Thread Mark J. Reed
On Sun, Mar 14, 2010 at 11:26 PM, Doug McNutt  wrote:
> Anything that can be made into a list is discrete.

Not quite, since you can create lists whose members belong to
continuous sets, e.g. real numbers.   Anything that naturally forms a
list, maybe.

> The other option is a function in the sense of the calculus that truly has an 
> infinite number of values.

The set of integers is both discrete and infinite.  Likewise rationals
and all the other "countable" sets.

The main thing that discrete sets have that continuous sets don't is
the ability to map them exactly onto a sequence.  Given an integer,
there's a single "next integer"; given a real number, there's
infinitely many - and infinitely many more real numbers in between the
start number and whichever "next" you choose.

> Perhaps the term atomic could be discreetly considered in place of discrete.

In CSland, I suspect "atomic" is too strongly associated with
operations to be applied to a data type that has nothing to do with
multithreading or transactional integrity.

-- 
Mark J. Reed 


r30092 - docs/Perl6/Spec

2010-03-15 Thread pugs-commits
Author: lwall
Date: 2010-03-15 18:39:10 +0100 (Mon, 15 Mar 2010)
New Revision: 30092

Modified:
   docs/Perl6/Spec/S03-operators.pod
Log:
[S03] add Z to go with X metaop
note that X and Z desugar to higher-order methods, crosswith and zipwith
speculate about how to zip/cross dwimmily with non-identical ops
possibly creating a real use case for surreal precedence  :)


Modified: docs/Perl6/Spec/S03-operators.pod
===
--- docs/Perl6/Spec/S03-operators.pod   2010-03-15 17:02:04 UTC (rev 30091)
+++ docs/Perl6/Spec/S03-operators.pod   2010-03-15 17:39:10 UTC (rev 30092)
@@ -15,8 +15,8 @@
 
 Created: 8 Mar 2004
 
-Last Modified: 2 Mar 2010
-Version: 196
+Last Modified: 15 Mar 2010
+Version: 197
 
 =head1 Overview
 
@@ -1732,6 +1732,9 @@
 
 1,2 Z 3,4   # (1,3),(2,4)
 
+The C operator is actually a degenerate case of the C zipwith
+metaoperator (see L below).
+
 =item *
 
 C<< infix: >>, the minmax operator
@@ -3841,14 +3844,16 @@
 operators yourself.  Similarly, the carets that exclude the endpoints
 on ranges are there by convention only.
 
-In contrast to that, Perl 6 has seven standard metaoperators for
+In contrast to that, Perl 6 has eight standard metaoperators for
 turning a given existing operator into a related operator that is
 more powerful (or at least differently powerful).  These differ from a
 mere naming convention in that Perl automatically generates these new
 operators from user-defined operators as well as from builtins.
 In fact, you're not generally supposed to define the individual
 metaoperations--their semantics are supposed to be self-evident by
-the transformation of the base operator.
+the transformation of the base operator.  In other words, these
+metaoperators are really just shorthand for higher-order functions
+(functions that take other functions as arguments).
 
 Constructs containing metaoperators are considered "metatokens",
 by which we mean that they are not subject to ordinary longest-token
@@ -4396,19 +4401,33 @@
 =head2 Cross operators
 
 The cross metaoperator, C, may be followed by any infix operator.
-It applies the
-modified operator across all groupings of its list arguments as returned
-by the ordinary C<< infix: >> operator.  All
-generated cross operators are of list infix precedence, and are list 
associative.
+It applies the modified operator across all groupings of its list
+arguments as returned by the ordinary C<< infix: >> operator.
+All generated cross operators are of list infix precedence, and are
+list associative.
 
 The string concatenating form is:
 
- X~ <1 2>   #  'a1', 'a2', 'b1', 'b2'
+ X~ 1,2   #  'a1', 'a2', 'b1', 'b2'
 
-The C operator desugars to something like:
+The C operator desugars to:
 
-[~]«(  X, <1 2> )  #  'a1', 'a2', 'b1', 'b2'
+(; 1,2).crosswith(&[~])
 
+which in turn means
+
+(; 1,2).cross.slice.map { .reduce(&[~]) }
+
+And
+
+ X~ 1,2 X+ 3,4
+
+might mean
+
+(; 1,2; 3,4).cross.slice.map { .reduce(&[~],&[+]) }
+
+(But see below.)
+
 The list concatenating form, C, when used like this:
 
  X, 1,2 X, 
@@ -4424,7 +4443,8 @@
 ('b', 2, 'x'),
 ('b', 2, 'y')
 
-The list form is common enough to have a shortcut, the ordinary infix
+The C operator is perhaps more clearly written as C.  However,
+this list form is common enough to have a shortcut, the ordinary infix
 C operator described earlier.
 
 For the general form, any existing, non-mutating infix operator
@@ -4447,8 +4467,85 @@
 Note that only the first term of an C operator may reasonably be
 an infinite list.
 
-Multidimensional lists should be handled properly.
+All lists are assumed to be flat; multidimensional lists are
+handled by treating the first dimension as the only dimension.
 
+=head2 Zip operators
+
+The zip metaoperator, C, may be followed by any infix operator.
+It applies the modified operator across all groupings of its list
+arguments as returned by the ordinary C<< infix: >> operator.
+All generated zip operators are of list infix precedence, and are
+list associative.
+
+The string concatenating form is:
+
+ Z~ 1,2   #  'a1', 'b2'
+
+The C operator desugars to:
+
+(; 1,2).zipwith(&[~])
+
+which in turn means
+
+(; 1,2).zip.slice.map { .reduce(&[~]) }
+
+And
+
+ Z~ 1,2 Z+ 3,4   #  'a4', 'b6'
+
+would mean
+
+(; 1,2; 3,4).zip.slice.map { .reduce(&[~],&[+]) }
+
+implying that multi-function reduce knows how to compare the precedence
+of its operator arguments somehow.  That seems unreasonable.  The clean
+way to solve this might involve giving C and C metaoperators a
+subprecedence within listop precedence corresponding to the original
+operator's precedence, so that C and C actually have different
+precedences within listop precedence.  Then the above would parse as if
+you'd said C<<  Z~ ( 1,2 Z+ 3,4> ) >>, but the lists would still
+parse at list infix precedence, with comma tighter than t

r30095 - docs/Perl6/Spec

2010-03-15 Thread pugs-commits
Author: lwall
Date: 2010-03-16 01:14:25 +0100 (Tue, 16 Mar 2010)
New Revision: 30095

Modified:
   docs/Perl6/Spec/S03-operators.pod
Log:
[S03] take conservative approach to differing X or Z metaops for now


Modified: docs/Perl6/Spec/S03-operators.pod
===
--- docs/Perl6/Spec/S03-operators.pod   2010-03-15 23:10:23 UTC (rev 30094)
+++ docs/Perl6/Spec/S03-operators.pod   2010-03-16 00:14:25 UTC (rev 30095)
@@ -16,7 +16,7 @@
 Created: 8 Mar 2004
 
 Last Modified: 15 Mar 2010
-Version: 197
+Version: 198
 
 =head1 Overview
 
@@ -4418,16 +4418,20 @@
 
 (; 1,2).cross.slice.map { .reduce(&[~]) }
 
-And
+Note that
 
  X~ 1,2 X+ 3,4
 
-might mean
+could mean something like
 
-(; 1,2; 3,4).cross.slice.map { .reduce(&[~],&[+]) }
+(; 1,2; 3,4).cross.slice.map { .reduce({$^a ~ $^b + $^c}) }
 
-(But see below.)
+but it is currently illegal as a non-identical list associative
+operator, which is considered non-associative.  You can, however,
+always use parens to be explicit:
 
+ X~ (1,2 X+ 3,4)
+
 The list concatenating form, C, when used like this:
 
  X, 1,2 X, 
@@ -4490,17 +4494,21 @@
 
 (; 1,2).zip.slice.map { .reduce(&[~]) }
 
-And
+Note that
 
- Z~ 1,2 Z+ 3,4   #  'a4', 'b6'
+ Z~ 1,2 Z+ 3,4
 
-would mean
+could mean something like
 
-(; 1,2; 3,4).zip.slice.map { .reduce(&[~],&[+]) }
+(; 1,2; 3,4).zip.slice.map { .reduce({$^a ~ $^b + $^c}) }
 
-implying that multi-function reduce knows how to compare the precedence
-of its operator arguments somehow.  That seems unreasonable.  The clean
-way to solve this might involve giving C and C metaoperators a
+but it is currently illegal as a non-identical list associative
+operator, which is considered non-associative.  You can, however,
+always use parens to be explicit:
+
+ Z~ (1,2 Z+ 3,4)
+
+[Conjecture: another approach would involve giving C and C metaoperators 
a
 subprecedence within listop precedence corresponding to the original
 operator's precedence, so that C and C actually have different
 precedences within listop precedence.  Then the above would parse as if
@@ -4508,7 +4516,7 @@
 parse at list infix precedence, with comma tighter than the zips.
 (This would actually be fairly trivial to implement, given how we
 represent our precedence as strings.)  Also, though it's complicated to
-explain, subprecedence within C might be exactly what the naive user 
expects.
+explain, subprecedence within C might be exactly what the naive user 
expects.]
 
 The list concatenating form, C, when used like this: