Re: [svn:perl6-synopsis] r14415 - doc/trunk/design/syn

2007-06-05 Thread Jonathan Lang

Larry Wall wrote:

: * In item context, a list of captures becomes a single Array object,
: and the question about whether or not it gets flattened gets deferred
: until its contents get looked at in list, slice, or hash context.

That's the intent.  $() used to assume @@ inside till this latest
change, but that seemed insufficiently lazy to me...

But it kinda means there's yet another list context that doesn't
decide yet, used explicitly by the insides of \(...) and implicitly
by the $() context.  Not sure if it needs a name yet, or whether it's
a design smell.


IMHO, no name is needed; just note that \(...) generates a variation
of the list context that is agnostic to flattening, but is otherwise
equivalent to list.


Arguably list should be non-committal and we give
@() a different name like flat, but that grates in my brain for
some reason, if only because most list contexts would in the end
be flat anyway.  And list in English already implies something
flatter than, say, an outline.


...which tends to be more akin to slice.  In fact, consider renaming
slice as outline.  Sure, it's two characters longer; but it's
_much_ more descriptive of what's going on.  Slice strikes me as
something of a holdover from its origins in array indices.

Conversely, our agnostic list _is_ flatter than a slice or outline,
just like a hardcore list is flatter than an agnostic list.  I'd tend
to agree about keeping list tied to the flattened stuff.  IMHO,
you're not going to find anything in English to represent the agnostic
list of captures.

In essence, we have: list, list-of-captures, and slice (or outline?);
also, hash and item.


: Meanwhile, 'zip' produces a list of captures - which, because list
: context is the default plural context, immediately gets flattened
: most of the time.  As I see it, then, the serial equivalent to
: 'zip(@a;@b)' would be '(@a;@b)', and 'list(@a;@b)' would be the serial
: equivalent to 'list(zip(@a;@b))'.

That doesn't make sense to me.  You seem to be thinking that semicolon
has zip semantics, when it doesn't.  All ; does is make a list of
captures.


My focus in this comparison is on what is being produced, rather than
on what is being passed in.

My understanding is that 'zip' produces a list of captures.  It's just
that the default context that zip is likely to work in is list
context, which flattens that list of captures.  Or am I wrong about
this?  The other alternative is that zip knows whether it's being
called in list or slice/outline context, and produces its output
accordingly.  I was assuming that zip wouldn't need to know; but I
could be wrong about this.

If zip _does_ tailor its return value according to the variety of list
context that it finds itself in, then 'list()' is _still_ not the
serial analog to 'zip()', any more than 'slice()' is, since both
impose a specific context on the product.  You'd need a new function
that takes a list of captures as its parameters, and produces a flat
list in list context or a slice or outline in slice/outline context.


: Or does '(@a;@b)' default to slice context?

Parentheses don't supply context.  They only group.  (@a;@b) returns
a list of captures.  It requires a binding (or other sigil) coercion
to supply context.


The parentheses weren't concerning me here; the semicolon within
brackets was.  I've been working under the assumption that a bracketed
@a;@b produces an agnostic list of captures, which then gets
flattened or structured when it hits list or slice context,
respectively; I was asking about the possibility that I was wrong
about this, and that bracket-within-semicolons produces a
slice/outline outright.

--

This does bring up another question, though: when are you in list
context, and when are you in list-of-captures context?  That is, when
do you force a list of captures to flatten, and when do you leave it
alone?

--
Jonathan Dataweaver Lang


Re: [svn:perl6-synopsis] r14415 - doc/trunk/design/syn

2007-06-05 Thread Jonathan Lang

Jonathan Lang wrote:

 Arguably list should be non-committal and we give
 @() a different name like flat, but that grates in my brain for
 some reason, if only because most list contexts would in the end
 be flat anyway.  And list in English already implies something
 flatter than, say, an outline.

...which tends to be more akin to slice.  In fact, consider renaming
slice as outline.  Sure, it's two characters longer; but it's
_much_ more descriptive of what's going on.  Slice strikes me as
something of a holdover from its origins in array indices.


An even better choice might be tree: it's the same length as list
and item, and conveys the hierarchal structure inherent to that
context quite nicely.

Then again, [[['a', 'b'], ['c', 'd']], 'e', ['f', 'g']] isn't really a
tree _or_ an outline, since only the leaf nodes actually have
content.

--
Jonathan Dataweaver Lang


PERL arrays

2007-06-05 Thread aislingbrennan21
how do i declare loop through and print a 4 dim array in PERL

thanks



Re: PERL arrays

2007-06-05 Thread Yuval Kogman
On Tue, Jun 05, 2007 at 14:36:51 -0700, [EMAIL PROTECTED] wrote:
 how do i declare loop through and print a 4 dim array in PERL

You listen in class. Or buy a book.

Sorry, but we're not here to do your homework, and this is not a
general Perl help mailing list.

You can also probably get by this far using some online tutorial.

-- 
  Yuval Kogman [EMAIL PROTECTED]
http://nothingmuch.woobling.org  0xEBD27418



pgpIQKKbvB8dY.pgp
Description: PGP signature


Re: PERL arrays

2007-06-05 Thread Juerd Waalboer
[EMAIL PROTECTED] skribis 2007-06-05 14:36 (-0700):
 how do i declare loop through and print a 4 dim array in PERL

Please note that Perl 6 is still not an acronym. It's not PERL, but
Perl.

Datastructures are documented in Synopsis 9, at
http://dev.perl.org/perl6/doc/design/syn/S09.html

I couldn't find how to loop over multidimensionally shaped arrays; maybe
you can and maybe someone can show an example.

...Are you sure you were asking about Perl 6?
-- 
korajn salutojn,

  juerd waalboer:  perl hacker  [EMAIL PROTECTED]  http://juerd.nl/sig
  convolution: ict solutions and consultancy [EMAIL PROTECTED]


Re: PERL arrays

2007-06-05 Thread Garrett Cooper

Yuval Kogman wrote:

On Tue, Jun 05, 2007 at 14:36:51 -0700, [EMAIL PROTECTED] wrote:
  

how do i declare loop through and print a 4 dim array in PERL



You listen in class. Or buy a book.

Sorry, but we're not here to do your homework, and this is not a
general Perl help mailing list.

You can also probably get by this far using some online tutorial.

  
   Read perldoc perldata or 
http://perldoc.perl.org/perldata.html#List-value-constructors-list 
(online version).
   Printing's trivial, and I'm pretty sure that allocation is the same 
(depending on what approach you take). I wonder -- does Perl allocate 
arrays optimizing for time (matrix-like) or space (nodes-like).

-Garrett