Re: List::oo - object interface to list methods

2007-11-26 Thread Jenda Krynicky
From: Eric Wilhelm [EMAIL PROTECTED]
 # from Jenda Krynicky
 # on Saturday 24 November 2007 17:00:

 I mean ... WHY would anyone want to write
 
   print L(qw(a b c))-map(sub {|$_|})-join(' '), \n;
 
 instead of
 
   print join( ' ', map {|$_|} qw(a b c)), \n;

 It is a flow from left to right rather than right to left.  Each method
 returns a list object, so extra map()s, grep()s, and etc just get
 appended to the right -- as opposed to jumping back to the beginning of
 the construct to add another transformation (and then messing with more
 parenthesis.)

Are you sure you'll only ever want to add the outmost (or rightmost)
transformation? And you do not seem to have less parens.

You seem to be too tied to the do this, then do this, then do this,
then do this, ... mindset. Try to stop restricting yourself to
statements. It doesn't have to be take x, compute the sinus, compute
the square root, it can just as well be compute the square root of
the sinus of x.

Or, taking that example, join the delimited values of the list.

What I'm trying to say is, try to switch the order in your head.
Don't specify the list/array, go back to the beginning of the line,
apply one transformation, return back to the beginning of the line,
apply another transformation, return back, apply transformation to a
single string, return back, print.

I do find myself returning when I write a complex statement, but I do
not remember ever returning to the beginning of the construct. I do
tend to write () or {} and later return to fill it in, but those are
exactly your leftmost arrayobject-transforming statements.

 (or in this particular case
   print |, join( '| |', qw(a b c)), |\n;
 )?

 Well, that would be bad practice because you've repeated your separator
 character and de-normalized the expression.  If you just don't like the
 example, feel free to write a better one.

Did I? The separator character is space, not the |. The | is a
delimiter. If there was just a separator it would look like this

  print join( ',', qw(a b c)), \n;

It's the delimiter that gets repeated. How often do you need/want to
change those? Anyway which one is better depends on circumstances, if
nothing else, without the map it's quicker. And I would not say it's
more complex, just the oposite.


Jenda
P.S.: Try to reverse this:
use List::MoreUtils qw(pairwise);
print join( ', ', pairwise {$a * $b} map( floor($_), @a), map(
ceil($_), @b)), \n;

= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery



Re: List::oo - object interface to list methods

2007-11-24 Thread Jenda Krynicky
From: Eric Wilhelm [EMAIL PROTECTED]
 Hi all,
 
 A reason to use lambda!  Actually, the reason I though of lambda in the 
 first place.

Great. And now for some reason to use List::oo.

I mean ... WHY would anyone want to write

  print L(qw(a b c))-map(sub {|$_|})-join(' '), \n;

instead of

  print join( ' ', map {|$_|} qw(a b c)), \n;
or
  print join( ' ', map |$_|, qw(a b c)), \n;

(or in this particular case

  print |, join( '| |', qw(a b c)), |\n;
) ?


You do not write

 $x-sin()-sqrt()

if you want the square root of the sinus of $x.
(Unless the language was designed by an OO purist of course.)

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery



Re: List::oo - object interface to list methods

2007-11-24 Thread A. Pagaltzis
* Jenda Krynicky [EMAIL PROTECTED] [2007-11-25 00:31]:
 And now for some reason to use List::oo.

Who cares? Sure, I agree, I don’t see the point either. Well,
apparently Eric does. But we don’t work on any codebase together,
so his opinion affects me not and mine him neither.

Hey look, we’re all writing Perl, and popular opinion these days
seems to be “why would anyone want to write Perl?” Let us not be
them ourselves.

Regards,
-- 
Aristotle Pagaltzis // http://plasmasturm.org/


Re: List::oo - object interface to list methods

2007-10-22 Thread Ricardo SIGNES
* Eric Wilhelm [EMAIL PROTECTED] [2007-10-22T02:10:07]
 Anyway, now it has a full set of bindings for everything (I think) in 
 List::Util and List::MoreUtils.

Seems a good bit like http://search.cpan.org/dist/Object-Array/, but with a
shorter constructor.

A SEE ALSO with a comparison would be nice.

-- 
rjbs


Re: List::oo - object interface to list methods

2007-10-22 Thread Eric Wilhelm
# from Ricardo SIGNES
# on Monday 22 October 2007 15:27:

Seems a good bit like http://search.cpan.org/dist/Object-Array/, but
 with a shorter constructor.

A SEE ALSO with a comparison would be nice.

Funny how these things tend to happen (without my hearing of them) after 
I start a module, but before I get it to CPAN.

# from Eric Wilhelm on Sunday 21 October 2007 23:10:
Some of you might remember discussing this some time ago when I was
hoping to call it list.pm.

some time ago was Feb 2006.

So, yeah.  Finally, or too late or whatever ;-)

--Eric
-- 
Atavism  n:  The recurrence of any peculiarity or disease of an ancestor
in a subsequent generation, usually due to genetic recombination.
---
http://scratchcomputing.com
---