Re: Ordering in \bbold{C}

2010-03-29 Thread Leon Timmermans
Maybe it's just me, but I don't see the value of having some
*arbitrary* predefined order for complex numbers. If people really
want to order their complex numbers, let them do it themselves in
whatever way they want.

Leon

On Mon, Mar 29, 2010 at 6:10 AM, Darren Duncan  wrote:
> I was actually thinking, during the previous thread involving Complex
> numbers ...
>
> It may not have any practical use, but if one wanted to define an ordering
> for complex numbers that was deterministic and relatively unbiased, a way to
> do this would be based on what I'll call for now the "spiral distance".
>
> Conceptually, you take an infinite length spiral line that starts at and is
> centered on the origin, where for each turn the current spot on the spiral
> increases an infinitesimal radius from the origin, or a distance approaching
> zero, in the calculus sense.  Complex numbers closer to the origin on the
> spiral will be ordered earlier than those further from the spiral.
>
> Actually calculating this is a simple comparison of the radius and angle
> components of the two complex numbers in the polar coordinate system.  If
> the radius value is different, then the one with the smaller radius is
> ordered before the one with the larger; if the two radius values are the
> same, then the one with the smaller angle is ordered first; if both are the
> same, then the two complex numbers are equal.
>
> The math is just as simple as a naive comparison that just compares the real
> component and then imaginary component in a cartesian coordinate system, but
> the result is much more reasonable I think.
>
> This whole principle of "distance from origin" method of ordering does also,
> I suspect, scale to any number of dimensions; the one-dimensional version is
> simply comparing first the absolute value of the two numbers, and then
> saying that either the positive or negative version orders first.
>
> -- Darren Duncan
>


Regex interpolation

2010-03-29 Thread Mark J. Reed
Is there not a way to run arbitrary code and interpolate the result as
a literal string (instead of a Regex)?

 I assume that {...} is intended to be where you hook in
semantics/actions mid-parse, but it seems a bit counter-intuitive that
the same syntax interpolates in double-quote context but not regexes.

Question Inspired by this Rakudo patch:
On Monday, March 29, 2010, Bruce Keeler  wrote:
> # New Ticket Created by  Bruce Keeler
> # Please include the string:  [perl #73862]
> # in the subject line of all future correspondence about this issue.
> # http://rt.perl.org/rt3/Ticket/Display.html?id=73862 >
>
>
> The attached patch adds support for variable and block-result
> interpolation into regexes.
>
> It does so by means of a new PAST::Regex node pasttype 'interpolator'.
> The following syntaxes are supported by this patch:
>
>     / $var /  -- Interpolates as literal string, unless it's a Regex object
>     / @foo / -- Interpolated as ||-style alternations of literal strings
> or Regex objects
>     / <$var> / -- compiled into a Regex (unless it's already one), then
> interpolated
>     / <@foo> / -- A list of ||-style alternations of things to be
> compiled into Regexes (unless they already are)
>     / <{ ... }> / -- Result of capture is interpolated as a Regex,
> compiling if necessary
>     /  / -- Unchanged
>     / { ... } / -- Capture is merely executed, but not interpolated.
> (Unchanged)
>

-- 
Mark J. Reed 


Re: Ordering in \bbold{C}

2010-03-29 Thread James Cloos
> "M" == Minimiscience   writes:

M> Assuming that the last line should be "A ≥ B if a₁ > b₁ ...",

Indeed, yes.  Is there a worse off-by-one typo than '<' vs '>'?

M> this is called lexicographic ordering,

Oh.  Yes.  Of course.  Obviosuly.  I should have noticed that and do not
know why I missed it.  [SIGH].  I guess I must think of lex ordering
mostly when thinking of /real/ polynomials  How narrow-minded. ☺

M> Specifically, because -1 is a square in ℂ, ℂ being an ordered field
M> would require that -1 > 0, which leads to a contradiction.

-JimC
-- 
James Cloos  OpenPGP: 1024D/ED7DAEA6


Re: Regex interpolation

2010-03-29 Thread mark . a . biggar
Use <{...}>. as the string returned is reinterpreted as a regex, if it consists 
of the single quoted string then it's a literal, but you must include the 
single quotes in the result returned.  E.g., 
<{ my $x = funct($a, $b, $c); "'$x'";}>

Mark Biggar
--
m...@biggar.org
mark.a.big...@comcast.net
mbig...@paypal.com

- Original Message -
From: Mark J. Reed 
To: perl6-language@perl.org
Sent: Mon, 29 Mar 2010 14:27:00 + (UTC)
Subject: Regex interpolation

Is there not a way to run arbitrary code and interpolate the result as
a literal string (instead of a Regex)?

 I assume that {...} is intended to be where you hook in
semantics/actions mid-parse, but it seems a bit counter-intuitive that
the same syntax interpolates in double-quote context but not regexes.

Question Inspired by this Rakudo patch:
On Monday, March 29, 2010, Bruce Keeler  wrote:
> # New Ticket Created by  Bruce Keeler
> # Please include the string:  [perl #73862]
> # in the subject line of all future correspondence about this issue.
> # 
>
>
> The attached patch adds support for variable and block-result
> interpolation into regexes.
>
> It does so by means of a new PAST::Regex node pasttype 'interpolator'.
> The following syntaxes are supported by this patch:
>
> / $var /  -- Interpolates as literal string, unless it's a Regex object
> / @foo / -- Interpolated as ||-style alternations of literal strings
> or Regex objects
> / <$var> / -- compiled into a Regex (unless it's already one), then
> interpolated
> / <@foo> / -- A list of ||-style alternations of things to be
> compiled into Regexes (unless they already are)
> / <{ ... }> / -- Result of capture is interpolated as a Regex,
> compiling if necessary
> / / -- Unchanged
> / { ... } / -- Capture is merely executed, but not interpolated.
> (Unchanged)
>

-- 
Mark J. Reed 



Re: You never have privacy from your children in Perl 6

2010-03-29 Thread Martin D Kealey
> On Mar 27, 2010, at 15:43 , Darren Duncan wrote:
> > For example, say you want to define a graph of some kind, and for
> > elegance you have a separate container and node and side classes,

On Sat, 27 Mar 2010, Brandon S. Allbery KF8NH wrote:
> This sounds like a hackaround for an incomplete implementation of ADTs.

No, it's simply a reflection that the one-to-one relationship between the
attributes of a single storage object is too simplistic to use as the *only*
encapsulation boundary.

Of course, that points towards having access limits that depend not just on
the type, but on the specific object: in Darren's example, nodes should be
able to see the details of the edges and faces they're attached to, but
probably not any other edges or faces. And definitely not the edges or faces
in some completely disconnected mesh or network.

A connected mesh or network is a reasonable ADT, but to implement it you're
going to want several classes. The mesh-object-as-a-whole is the appropriate
encapsulation boundary.

If we had a really sophisticated ADT that could represent a "Network", that
would indeed solve the encapsulation problem. So what tools are we going to
need to build such an ADT? Well, privacy, trust, ...

-Martin


Re: Ordering in \bbold{C}

2010-03-29 Thread Darren Duncan

Leon Timmermans wrote:

Maybe it's just me, but I don't see the value of having some
*arbitrary* predefined order for complex numbers. If people really
want to order their complex numbers, let them do it themselves in
whatever way they want.
Leon


I agree actually that Complex shouldn't have a predefined order.  I just raised 
my algorithm since someone else raised another one. -- Darren Duncan




Re: You never have privacy from your children in Perl 6

2010-03-29 Thread Darren Duncan

Martin D Kealey wrote:

On Mar 27, 2010, at 15:43 , Darren Duncan wrote:

For example, say you want to define a graph of some kind, and for
elegance you have a separate container and node and side classes,


On Sat, 27 Mar 2010, Brandon S. Allbery KF8NH wrote:

This sounds like a hackaround for an incomplete implementation of ADTs.


No, it's simply a reflection that the one-to-one relationship between the
attributes of a single storage object is too simplistic to use as the *only*
encapsulation boundary.

Of course, that points towards having access limits that depend not just on
the type, but on the specific object: in Darren's example, nodes should be
able to see the details of the edges and faces they're attached to, but
probably not any other edges or faces. And definitely not the edges or faces
in some completely disconnected mesh or network.


I agree.  And in my experience actually implementing said graph thingy, one of 
the things I regularly had to test is whether an object I was given as an 
argument is in the same network as another one, and the easiest way to do that 
is to test if both have the same container object.


FYI, that graph implementation was the now-deprecated 
http://search.cpan.org/~duncand/Rosetta-v0.71.0/lib/Rosetta/Model.pm (aka 
SQL::Routine), last substantially updated in mid-2005.  This url is a Perl 5 
version, but I had also ported it to Perl 6 in the first few months of Pugs' 
existence to help test Pugs, though it was soon after wiped from Pugs' repo, as 
they added the policy that most ext/ things should actually be distributed 
separately from Pugs, or there was some reason.


-- Darren Duncan


A connected mesh or network is a reasonable ADT, but to implement it you're
going to want several classes. The mesh-object-as-a-whole is the appropriate
encapsulation boundary.

If we had a really sophisticated ADT that could represent a "Network", that
would indeed solve the encapsulation problem. So what tools are we going to
need to build such an ADT? Well, privacy, trust, ...

-Martin