[32057] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3321 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 15 16:09:29 2011

Date: Tue, 15 Mar 2011 13:09:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 15 Mar 2011     Volume: 11 Number: 3321

Today's topics:
        array not printing what I want <rodbass63@gmail.com>
    Re: array not printing what I want <hjp-usenet2@hjp.at>
        attn new users: IGNORE PREVIOUS MESSAGE <ralph@happydays.com>
    Re: attn new users: IGNORE PREVIOUS MESSAGE (Randal L. Schwartz)
    Re: convenient module to take statistics for hashed str <nospam.gravitalsun@hotmail.com.nospam>
    Re: convenient module to take statistics for hashed str <tadmc@seesig.invalid>
    Re: convenient module to take statistics for hashed str <hjp-usenet2@hjp.at>
    Re: convenient module to take statistics for hashed str <uri@StemSystems.com>
        Hash <smilesonisamal@gmail.com>
    Re: Hash <nospam.gravitalsun@hotmail.com.nospam>
    Re: Hash <jimsgibson@gmail.com>
    Re: Ok, simpler..... <justin.1102@purestblue.com>
        recursive Pythagorian triples <cartercc@gmail.com>
    Re: recursive Pythagorian triples <glennj@ncf.ca>
    Re: recursive Pythagorian triples <nospam.gravitalsun@hotmail.com.nospam>
    Re: recursive Pythagorian triples <nospam.gravitalsun@hotmail.com.nospam>
    Re: recursive Pythagorian triples <hjp-usenet2@hjp.at>
    Re: recursive Pythagorian triples <hjp-usenet2@hjp.at>
    Re: recursive Pythagorian triples <nospam.gravitalsun@hotmail.com.nospam>
    Re: recursive Pythagorian triples <nospam.gravitalsun@hotmail.com.nospam>
    Re: recursive Pythagorian triples <peter@makholm.net>
        Salesforce.com Top Buzz ----ASC Promoting Salesforce.co <click2asc@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 15 Mar 2011 05:14:50 -0700 (PDT)
From: Nene <rodbass63@gmail.com>
Subject: array not printing what I want
Message-Id: <bfde793c-606c-40d4-8b21-27dc5985aba6@k18g2000vbb.googlegroups.com>

#!/usr/bin/perl -w
use strict;

my $SUBNET  = '172.16.70.';
my @MEMBERS = qw/
${SUBNET}66
${SUBNET}68
${SUBNET}70
${SUBNET}72
/;

foreach my $node ( @MEMBERS )

{
print "$node\n"
}

####

I want it to print the IP address.



------------------------------

Date: Tue, 15 Mar 2011 13:45:34 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: array not printing what I want
Message-Id: <slrninunrf.2ip.hjp-usenet2@hrunkner.hjp.at>

On 2011-03-15 12:14, Nene <rodbass63@gmail.com> wrote:
> my $SUBNET  = '172.16.70.';
> my @MEMBERS = qw/
> ${SUBNET}66
> ${SUBNET}68
> ${SUBNET}70
> ${SUBNET}72
> /;

See perldoc perlop, "Quote and Quote-like Operators" for why this
doesn't work.

To interpolate you need to use double quotes:

my @MEMBERS = (
    "${SUBNET}66",
    "${SUBNET}68",
    "${SUBNET}70",
    "${SUBNET}72",
);

and of course in this case a map could be used to save typing:

my @MEMBERS = map "${SUBNET}$_", qw(66 68 70 72);

	hp


------------------------------

Date: Tue, 15 Mar 2011 12:16:30 -0400
From: Ralph Malph <ralph@happydays.com>
Subject: attn new users: IGNORE PREVIOUS MESSAGE
Message-Id: <50efc$4d7f90de$ce534406$15300@news.eurofeeds.com>

Dear newcomers to this newsgroup.
Please ignore the previous message as it is being spammed to this group
by an Asperberger's victim. Due to his affliction, he lacks basic
social skills. The lack of writing skills is just a sad coincidence.


------------------------------

Date: Tue, 15 Mar 2011 10:14:48 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: attn new users: IGNORE PREVIOUS MESSAGE
Message-Id: <86k4g01f1z.fsf@red.stonehenge.com>

>>>>> "Ralph" == Ralph Malph <ralph@happydays.com> writes:

Ralph> Dear newcomers to this newsgroup.
Ralph> Please ignore the previous message as it is being spammed to this group
Ralph> by an Asperberger's victim. Due to his affliction, he lacks basic
Ralph> social skills. The lack of writing skills is just a sad
Ralph> coincidence.

And instead, we should believe someone who is apparently hiding
behing a fake name, and causing spam to be delivered to an innocent
bystander[1].  Really?  Your credibility is laughable.

[1] Unless you happen to be:

    Registrant:
     HappyDays, Inc.
     P.O. Box 308
     Terral, OK 73569
     US

     Domain name: HAPPYDAYS.COM


     Administrative Contact:
        Day, Scott  admin@happydays.com
        P.O. Box 308
        Terral, OK 73569
        US
        580-475-9000    Fax: 580-475-9003

     Technical Contact:
        Day, Scott  admin@happydays.com
        4245 Kemp Blvd, #818
        wichita falls, tx 76308
        US
        940-691-1800    Fax: 940-691-1803



     Registrar of Record: TUCOWS, INC.
     Record last updated on 02-Mar-2011.
     Record expires on 27-Mar-2012.
     Record created on 26-Mar-1997.

     Registrar Domain Name Help Center:
        http://tucowsdomains.com

     Domain servers in listed order:
        NS2.OKDIRECT.COM
        NS.OKDIRECT.COM


     Domain status: clientTransferProhibited
                    clientUpdateProhibited

But I really would need to see some proof.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion


------------------------------

Date: Tue, 15 Mar 2011 14:39:17 +0200
From: "George Mpouras" <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: convenient module to take statistics for hashed structures?
Message-Id: <ilnmka$2gnf$1@news.ntua.gr>

# The following version is much faster than the previous


my @col;
my %data;
ReadData();


$_ = query('NODE_124_length_77_cov_13.792208',  100);
print "Field=$_->[0],Value=@{$_->[1]}\n";

$_ = query('NODE_124_length_77_cov_13.792208',   50);
print "Field=$_->[0],Value=@{$_->[1]}\n";



sub ReadData
{
while (<DATA>) {
chomp;
my @a = split /\s*\|\s*/, $_, -1;
if (-1 == $#col){ push @col, @a[1..$#a] ;next}
$data{$a[0]}->[0]++;
for(my $i=1;$i<=$#a;$i++){$data{$a[0]}->[1]->[$i-1]->[0]->{$a[$i]}++} }
foreach my $id ( keys %data ) {
foreach my $f  ( @{$data{$id}->[1]} ) {
foreach my $v  ( keys %{$f->[0]} ) {
push @{ $f->[1]->{int 100*( $f->[0]->{$v}/$data{$id}->[0])} }, $v}}}
#use Data::Dumper; print Dumper(\%data);exit;
}


sub query {
for (my $i=$#{$data{$_[0]}->[1]}; $i>=0; $i--) {
return [$col[$i], $data{$_[0]}->[1]->[$i]->[1]->{$_[1]}] if exists 
$data{$_[0]}->[1]->[$i]->[1]->{$_[1]} }
['',[]]
}


__DATA__
Identity of query sequence       | Superkingdom  | Kingdom | Subkingdom | 
Phylum         | Class                | Order             | Family 
| Genus       | Species2 | group      | Species
NODE_124_length_77_cov_13.792208 | Bacteria      | undef   | undef      | 
Proteobacteria | Gammaproteobacteria  | Enterobacteriales | 
Enterobacteriaceae | Escherichia | undef   | Escherichi1 | coli
NODE_124_length_77_cov_13.792208 | Bacteria      | undef   | undef      | 
Proteobacteria | Gammaproteobacteria  | Enterobacteriales | 
Enterobacteriaceae | Escherichia | undef   | Escherichi2 | coli 




------------------------------

Date: Tue, 15 Mar 2011 08:15:07 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: convenient module to take statistics for hashed structures?
Message-Id: <slrninup9b.s4v.tadmc@tadbox.sbcglobal.net>

ela <ela@yantai.org> wrote:

>  foreach my $field (reverse sort {$a<=>$b} keys %col) {


You are already specifying the sort order, so why specify it
in the opposite order from what you want and then reverse it
to get the order that you really wanted?

You should just specify the order that you really want in the
first place:

    foreach my $field (sort {$b<=>$a} keys %col) {
                             ^^   ^^
                             ^^   ^^

-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Tue, 15 Mar 2011 14:55:13 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: convenient module to take statistics for hashed structures?
Message-Id: <slrninuru2.31e.hjp-usenet2@hrunkner.hjp.at>

On 2011-03-15 12:39, George Mpouras <nospam.gravitalsun@hotmail.com.nospam> wrote:
> foreach my $id ( keys %data ) {
> foreach my $f  ( @{$data{$id}->[1]} ) {
> foreach my $v  ( keys %{$f->[0]} ) {
> push @{ $f->[1]->{int 100*( $f->[0]->{$v}/$data{$id}->[0])} }, $v}}}
[...]
> __DATA__
> Identity of query sequence       | Superkingdom  | Kingdom | Subkingdom | 
> Phylum         | Class                | Order             | Family 
>| Genus       | Species2 | group      | Species
> NODE_124_length_77_cov_13.792208 | Bacteria      | undef   | undef      | 
> Proteobacteria | Gammaproteobacteria  | Enterobacteriales | 
> Enterobacteriaceae | Escherichia | undef   | Escherichi1 | coli
[...]

When posting code to a newsgroup, please ensure that proper indentation
and line wraps are preserved. This is very hard to read because of the
missing indentation and doesn't work as posted because of the extra
newlines.

	hp



------------------------------

Date: Tue, 15 Mar 2011 12:48:31 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: convenient module to take statistics for hashed structures?
Message-Id: <87tyf4uy74.fsf@quad.sysarch.com>

>>>>> "GM" == George Mpouras <nospam.gravitalsun@hotmail.com.nospam> writes:

  >> 
  >> our doesn't create a variable. it only creates a lexical alias to the
  >> variable of the same name in the current package.

  GM> Alias of what if our is only the definition ;
  GM> #!/usr/bin/perl
  GM> our $var=1;
  GM> print $var;
  GM> exit 0 

the current package as i said. what is the default current package?

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Tue, 15 Mar 2011 10:58:55 -0700 (PDT)
From: Pradeep Patra <smilesonisamal@gmail.com>
Subject: Hash
Message-Id: <4a3ce65d-0cd4-4da9-8cba-f3cbd9553046@o30g2000pra.googlegroups.com>

Hi all,
   I am new to perl. While doing some sample programs I am getting a
issue as follows.

I have a HASH as follows
$VAR1 = [
          {
            'A-list' => [
                                   {
                                     'B-info' => [


{


'name' => 'd',


'time' => '0',


'virtual' => 'v1',


'f1' => '0'
                                                                        }.


{


'name' => 'n2',


'time' => '0',


'virtual' => 'v1',


'f1' => '0'
                                                                        }.


                                  ]


 I want to search the line virtual="v1" from all the records in the
above hash and then in that record i want to check name is "d" and if
it is true return 1 else return 0. I am trying to do as follows for
testing whether the name returns "d" or not. But $name returns empty
string. Can anybody tell me what I am doing wrong for which i will
appreciate?


my $name = $VAR1{"A-list"}->{"B-info"}->[0]->{'name'};


my $name = $VAR1{"A-list"}->{"B-info"}->[0]->{"name"}; (Same results
$name returns empty string)


------------------------------

Date: Tue, 15 Mar 2011 21:22:00 +0200
From: George Mpouras <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: Hash
Message-Id: <iloe8n$212c$1@news.ntua.gr>

Στις 15/3/2011 7:58 μμ, ο/η Pradeep Patra έγραψε:
> Hi all,
>     I am new to perl. While doing some sample programs I am getting a
> issue as follows.
>
> I have a HASH as follows
> $VAR1 = [
>            {
>              'A-list' =>  [
>                                     {
>                                       'B-info' =>  [
>
>
> {
>
>
> 'name' =>  'd',
>
>
> 'time' =>  '0',
>
>
> 'virtual' =>  'v1',
>
>
> 'f1' =>  '0'
>                                                                          }.
>
>
> {
>
>
> 'name' =>  'n2',
>
>
> 'time' =>  '0',
>
>
> 'virtual' =>  'v1',
>
>
> 'f1' =>  '0'
>                                                                          }.
>
>
>                                    ]
>
>
>   I want to search the line virtual="v1" from all the records in the
> above hash and then in that record i want to check name is "d" and if
> it is true return 1 else return 0. I am trying to do as follows for
> testing whether the name returns "d" or not. But $name returns empty
> string. Can anybody tell me what I am doing wrong for which i will
> appreciate?
>
>
> my $name = $VAR1{"A-list"}->{"B-info"}->[0]->{'name'};
>
>
> my $name = $VAR1{"A-list"}->{"B-info"}->[0]->{"name"}; (Same results
> $name returns empty string)







$VAR1 =
[
     {
     'A-list'=>
         [
             {
             'B-info'=>
                 [
                 {'name'=>'d' ,'time'=>'0','virtual'=>'v1','f1'=> '0'},
                 {'name'=>'n2','time'=>'0','virtual'=>'v1','f1'=> '0'}
                 ]
             }
         ]
     }
];



my $alias = $VAR1->[0]{'A-list'}[0]{'B-info'}[0];

print (($alias->{'virtual'} eq 'v1' && $alias->{'name'} eq 'd')?1:0);



#Peace


------------------------------

Date: Tue, 15 Mar 2011 12:37:52 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Hash
Message-Id: <150320111237520878%jimsgibson@gmail.com>

In article
<4a3ce65d-0cd4-4da9-8cba-f3cbd9553046@o30g2000pra.googlegroups.com>,
Pradeep Patra <smilesonisamal@gmail.com> wrote:

> Hi all,
>    I am new to perl. While doing some sample programs I am getting a
> issue as follows.
> 
> I have a HASH as follows
> $VAR1 = [

The '[' indicates an array reference, not a hash and not a hash
reference. The elements of the array can be referenced with the
notation $VAR->[0], $VAR->[1], etc. Those elements happen to be
references to a hash.


>           {
>             'A-list' => [

The value of the element of the hash referred to by $VAR->[0] that has
the key 'A-list' is a reference to an array. The elements of this array
are $VAR->[0]->{'A-list'}->[0], etc.

>                                    {
>                                      'B-info' => [
> 
> 
> {
> 
> 
> 'name' => 'd',
> 
> 
> 'time' => '0',
> 
> 
> 'virtual' => 'v1',
> 
> 
> 'f1' => '0'
>                                                                         }.
> 
> 
> {
> 
> 
> 'name' => 'n2',
> 
> 
> 'time' => '0',
> 
> 
> 'virtual' => 'v1',
> 
> 
> 'f1' => '0'
>                                                                         }.
> 
> 
>                                   ]
> 
> 
>  I want to search the line virtual="v1" from all the records in the
> above hash and then in that record i want to check name is "d" and if
> it is true return 1 else return 0. I am trying to do as follows for
> testing whether the name returns "d" or not. But $name returns empty
> string. Can anybody tell me what I am doing wrong for which i will
> appreciate?
> 
> 
> my $name = $VAR1{"A-list"}->{"B-info"}->[0]->{'name'};

my $name = $VAR->[0]->{'A-list'}->[0]->{'name'};

-- 
Jim Gibson


------------------------------

Date: Tue, 15 Mar 2011 10:50:58 +0000
From: Justin C <justin.1102@purestblue.com>
Subject: Re: Ok, simpler.....
Message-Id: <its358-j4t.ln1@zem.masonsmusic.co.uk>

On 2011-03-14, ccc31807 <cartercc@gmail.com> wrote:
> I've never heard your version. Some points: (1) You 'build' a fire,
> not 'give' a fire. How do you give a man a fire? When you give a man a
> fish, he consumes it. When you build a fire, the man consumes the heat
> from the fire, not the fire itself.

And the Academy Award for pedantry goes to ...

   Justin.

-- 
Justin C, by the sea.


------------------------------

Date: Tue, 15 Mar 2011 10:30:37 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: recursive Pythagorian triples
Message-Id: <3e2bf9e1-93bf-4750-87ea-4d557da66739@d26g2000prn.googlegroups.com>

Pythagorian triples are integers that form the sides of a right
triangle, e.g., 3, 4, 5. I've posted an iterative version below for
all triples less than 100. I'm having trouble coming up with a
recursive version. Any ideas?

CC

#! perl
use strict;
use warnings;
print "Pythagorian triples\n\n";

for(my $i = 1; $i < 101; $i++)
{
  for(my $j = 1; $j < 101; $j++)
  {
    for(my $k = 1; $k < 101; $k++)
    {
      print "$i - $j - $k\n" if ($i * $i + $j * $j) == ($k * $k);
    }
  }
}
exit(0);


------------------------------

Date: 15 Mar 2011 17:58:58 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: recursive Pythagorian triples
Message-Id: <slrninva73.qk5.glennj@smeagol.ncf.ca>

At 2011-03-15 01:30PM, "ccc31807" wrote:
>  Pythagorian triples are integers that form the sides of a right
>  triangle, e.g., 3, 4, 5. I've posted an iterative version below for
>  all triples less than 100. I'm having trouble coming up with a
>  recursive version. Any ideas?
>  
>  CC
>  
>  #! perl
>  use strict;
>  use warnings;
>  print "Pythagorian triples\n\n";
>  
>  for(my $i = 1; $i < 101; $i++)
>  {
>    for(my $j = 1; $j < 101; $j++)
>    {
>      for(my $k = 1; $k < 101; $k++)
>      {
>        print "$i - $j - $k\n" if ($i * $i + $j * $j) == ($k * $k);
>      }
>    }
>  }
>  exit(0);

Not recursive, but the RosettaCode site
(http://rosettacode.org/wiki/List_comprehensions#Perl) 
has this implementation

    sub triples ($) {
        my ($n) = @_;
        map { 
            my $x = $_; 
            map { 
                my $y = $_; 
                map { [$x, $y, $_] } 
                    grep { $x**2 + $y**2 == $_**2 } 1..$n 
            } 1..$n 
        } 1..$n;
    }


-- 
Glenn Jackman
    Write a wise saying and your name will live forever. -- Anonymous


------------------------------

Date: Tue, 15 Mar 2011 20:34:09 +0200
From: George Mpouras <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: recursive Pythagorian triples
Message-Id: <ilobf0$1pd6$1@news.ntua.gr>

Στις 15/3/2011 7:58 μμ, ο/η Glenn Jackman έγραψε:
> At 2011-03-15 01:30PM, "ccc31807" wrote:
>>   Pythagorian triples are integers that form the sides of a right
>>   triangle, e.g., 3, 4, 5. I've posted an iterative version below for
>>   all triples less than 100. I'm having trouble coming up with a
>>   recursive version. Any ideas?
>>
>>   CC
>>
>>   #! perl
>>   use strict;
>>   use warnings;
>>   print "Pythagorian triples\n\n";
>>
>>   for(my $i = 1; $i<  101; $i++)
>>   {
>>     for(my $j = 1; $j<  101; $j++)
>>     {
>>       for(my $k = 1; $k<  101; $k++)
>>       {
>>         print "$i - $j - $k\n" if ($i * $i + $j * $j) == ($k * $k);
>>       }
>>     }
>>   }
>>   exit(0);
>
> Not recursive, but the RosettaCode site
> (http://rosettacode.org/wiki/List_comprehensions#Perl)
> has this implementation
>
>      sub triples ($) {
>          my ($n) = @_;
>          map {
>              my $x = $_;
>              map {
>                  my $y = $_;
>                  map { [$x, $y, $_] }
>                      grep { $x**2 + $y**2 == $_**2 } 1..$n
>              } 1..$n
>          } 1..$n;
>      }
>
>


this is the same as OP


------------------------------

Date: Tue, 15 Mar 2011 20:34:46 +0200
From: George Mpouras <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: recursive Pythagorian triples
Message-Id: <ilobg5$1pd6$2@news.ntua.gr>

# This is pretty fast

my $iterator= &BuildIterator;

$iterator->(4);

sub BuildIterator {
return sub {
for (my $i=1; $i<=$_[0]; $i++) {
for (my $j=1; $j<$i; $j++)     {
print STDOUT join(',', ($i**2 - $j**2) , 2*$i*$j , ($i**2 + $j**2))."\n" }}}
}


------------------------------

Date: Tue, 15 Mar 2011 19:49:48 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: recursive Pythagorian triples
Message-Id: <slrninvd6c.5kq.hjp-usenet2@hrunkner.hjp.at>

On 2011-03-15 17:30, ccc31807 <cartercc@gmail.com> wrote:
> Pythagorian triples are integers that form the sides of a right
> triangle, e.g., 3, 4, 5. I've posted an iterative version below for
> all triples less than 100. I'm having trouble coming up with a
> recursive version. Any ideas?

Not sure why you would want to do this, but here is a straightforward
solution:


#!/usr/bin/perl

use warnings;
use strict;

no warnings 'recursion';

test_c(100);

sub test_c {
    my ($c) = @_;

    if ($c > 1) {
	test_c($c - 1);
    }
    test_b($c, $c);
}

sub test_b {
    my ($b, $c) = @_;

    if ($b > 1) {
	test_b($b - 1, $c);
    }

    test_a($b, $b, $c);
}

sub test_a {
    my ($a, $b, $c) = @_;

    if ($a > 1) {
	test_a($a - 1, $b, $c);
    }

    print "$a $b $c\n" if ($a * $a + $b * $b == $c * $c);
}
__END__

Note: If you don't care about the output order, this can easily be made
tail-recursive (doesn't help with perl, but usually does with functional
languages).

	hp


------------------------------

Date: Tue, 15 Mar 2011 20:22:08 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: recursive Pythagorian triples
Message-Id: <slrninvf32.5u7.hjp-usenet2@hrunkner.hjp.at>

On 2011-03-15 18:34, George Mpouras <nospam.gravitalsun@hotmail.com.nospam> wrote:
> # This is pretty fast
>
> my $iterator= &BuildIterator;
>
> $iterator->(4);
>
> sub BuildIterator {
> return sub {
> for (my $i=1; $i<=$_[0]; $i++) {
> for (my $j=1; $j<$i; $j++)     {
> print STDOUT join(',', ($i**2 - $j**2) , 2*$i*$j , ($i**2 + $j**2))."\n" }}}
> }

But:

 * No recursion.

 * Doesn't print all pythogarean triples with a, b, c <= 100
   (for example it doesn't print 6, 8, 10).

 * It isn't obvious that the tupels it produces are indeed pythogarean
   triples (yes, the proof is simple, but you need to do it).

 * What's with the anonymous sub? That's completely unnecessary.

	hp


------------------------------

Date: Tue, 15 Mar 2011 21:24:13 +0200
From: George Mpouras <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: recursive Pythagorian triples
Message-Id: <iloecs$212c$2@news.ntua.gr>

Στις 15/3/2011 9:22 μμ, ο/η Peter J. Holzer έγραψε:
>   * What's with the anonymous sub? That's completely unnecessary.
>
> 	hp

Its beautiful !


------------------------------

Date: Tue, 15 Mar 2011 21:27:06 +0200
From: George Mpouras <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: recursive Pythagorian triples
Message-Id: <iloei9$212c$3@news.ntua.gr>

Στις 15/3/2011 9:22 μμ, ο/η Peter J. Holzer έγραψε:
> On 2011-03-15 18:34, George Mpouras<nospam.gravitalsun@hotmail.com.nospam>  wrote:
>> # This is pretty fast
>>
>> my $iterator=&BuildIterator;
>>
>> $iterator->(4);
>>
>> sub BuildIterator {
>> return sub {
>> for (my $i=1; $i<=$_[0]; $i++) {
>> for (my $j=1; $j<$i; $j++)     {
>> print STDOUT join(',', ($i**2 - $j**2) , 2*$i*$j , ($i**2 + $j**2))."\n" }}}
>> }
>
> But:
>
>   * No recursion.
>
>   * Doesn't print all pythogarean triples with a, b, c<= 100
>     (for example it doesn't print 6, 8, 10).
>
>   * It isn't obvious that the tupels it produces are indeed pythogarean
>     triples (yes, the proof is simple, but you need to do it).
>
>   * What's with the anonymous sub? That's completely unnecessary.
>
> 	hp


Ah, the 6,8,10 is the second printed line !


------------------------------

Date: Tue, 15 Mar 2011 21:03:13 +0100
From: Peter Makholm <peter@makholm.net>
Subject: Re: recursive Pythagorian triples
Message-Id: <87r5a8rw1q.fsf@vps1.hacking.dk>

"Peter J. Holzer" <hjp-usenet2@hjp.at> writes:

> Note: If you don't care about the output order, this can easily be made
> tail-recursive (doesn't help with perl, but usually does with functional
> languages).

You could implemt tail recursion using 'goto &func'. Not a very nice
syntax, but possible to emulate.

//Makholm


------------------------------

Date: Tue, 15 Mar 2011 04:51:47 -0700 (PDT)
From: Aspire Software Consultancy <click2asc@gmail.com>
Subject: Salesforce.com Top Buzz ----ASC Promoting Salesforce.com in India
Message-Id: <1412af6d-3f16-4fa1-a58b-cbc9f36fe955@z3g2000prz.googlegroups.com>

For salesforce.com, Growth Won't Come Cheap - Motley Fool

'Mad Money Lightning Round': Stick With Salesforce.com - TheStreet.com

Cloud9 Analytics names CEO - Bizjournals.com

Pundit Calls Salesforce Cloud Claim 'Wishful Thinking' - Internet.com

Tsunami waves put data centers at risk - msnbc.com

The Future of Corporate IT is Private Cloud Computing - Fresh Business
Thinking

Salesforce Stock Sensitive to Research and Development Spend - Seeking
Alpha

Salesforce.com CEO Has a Front-Office Vision - eCRM Guide

Behind HubSpot's $32M investment from Salesforce, Google and Sequoia -
Mass High Tech

Gavin Joins The HRA Group's Salesforce - Diamonds.net

Salesforce.com CEO Has a Front-Office Vision - eCRM Guide

Behind HubSpot's $32M investment from Salesforce, Google and Sequoia -
Mass High Tech

Salesforce.com (CRM) And Oracle (ORCL) Benefit From Open Source and
Cloud Computing Based Applications That Will Lead ..

SaaS leader Salesforce.com is growing so fast that the company is
considering the possibility of building its own data centers within
the next few years, Rich Miller reported at Data Center Knowledge
Cloud consulting and development specialist, Saaspoint
(www.saaspoint.com) has launched its new European Data Manager product
to provide best of breed data management and integrity to
salesforce.com users.

RAE Internet, Inc. has announced the release of their no software
solution to integrate Apple Mail and Salesforce.com, Match My Email.

Marketsync, Inc., the only provider of an integrated correspondence
solution for Salesforce CRM, announced that it has added Marketo, a
leading Marketing Automation Revenue Performance Management solution
provider.

Given all this, it's hardly surprising that Salesforce.com, a CRM
provider that's been known to dabble in BPM, just introduced Service
Cloud 3.


Website: http://www.aspiresoftwareconsultancy.com/

Call Lalit :
IN: +91-80-2668340
Skype : lalit.mendapara


Follow ASC on twitter: http://twitter.com/ascaspirents#
Join me on Linkedin: http://in.linkedin.com/pub/lalit-aspire-software-consultancy/28/a6/1a8




--


Aspire Software Consultancy
No. 3, Brindavan Complex,
BTM 1st Stage, 20th Main,
Marutinagar Road,
Bangalore500079 .
I N D I A


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 3321
***************************************


home help back first fref pref prev next nref lref last post