[27934] in Perl-Users-Digest
Perl-Users Digest, Issue: 9298 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 14 18:10:17 2006
Date: Wed, 14 Jun 2006 15:10:10 -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 Wed, 14 Jun 2006 Volume: 10 Number: 9298
Today's topics:
size of anonymous array <jtbutler78@comcast.net>
Re: size of anonymous array lawrence@hummer.not-here.net
Re: size of anonymous array <jtbutler78@comcast.net>
Re: size of anonymous array <simon.chao@fmr.com>
Re: size of anonymous array lawrence@hummer.not-here.net
Re: size of anonymous array <jgibson@mail.arc.nasa.gov>
Re: size of anonymous array <mritty@gmail.com>
Re: size of anonymous array <tadmc@augustmail.com>
Re: What is Expressiveness in a Computer Language <jo@durchholz.org>
Re: What is Expressiveness in a Computer Language <jo@durchholz.org>
Re: What is Expressiveness in a Computer Language <jo@durchholz.org>
Re: What is Expressiveness in a Computer Language <pc@p-cos.net>
Re: What is Expressiveness in a Computer Language <pjb@informatimago.com>
XMLRPC::Lite <wishmasterCUT@poczta.onet.pl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Jun 2006 11:32:03 -0700
From: "jtbutler78@comcast.net" <jtbutler78@comcast.net>
Subject: size of anonymous array
Message-Id: <1150309923.250349.15280@f6g2000cwb.googlegroups.com>
I have a hash with the values being arrays. How can I find the size of
these arrays?
example:
$hash{$key} = [ 0, 1];
$hash{$key1} = [ 0, 1];
$hash{$key2} = [ 0, 1,2];
$hash{$key3} = [ 0];
thanks
------------------------------
Date: 14 Jun 2006 11:42:36 -0700
From: lawrence@hummer.not-here.net
Subject: Re: size of anonymous array
Message-Id: <87ac8fpoir.fsf@hummer.i-did-not-set--mail-host-address--so-shoot-me>
"jtbutler78@comcast.net" <jtbutler78@comcast.net> writes:
> I have a hash with the values being arrays. How can I find the size of
> these arrays?
>
> example:
> $hash{$key} = [ 0, 1];
> $hash{$key1} = [ 0, 1];
> $hash{$key2} = [ 0, 1,2];
> $hash{$key3} = [ 0];
>
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %hash = ( foo => [ 0,1 ] ,
bar => [ 0,1 ] ,
baz => [ 0,1,2 ],
waldo => [ 0] );
my $sum;
$sum += @$_ for values %hash;
print "total length = $sum\n";
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer software consists of only two components: ones and
zeros, in roughly equal proportions. All that is required is to
sort them into the correct order.
------------------------------
Date: 14 Jun 2006 11:48:03 -0700
From: "jtbutler78@comcast.net" <jtbutler78@comcast.net>
Subject: Re: size of anonymous array
Message-Id: <1150310883.548912.50660@p79g2000cwp.googlegroups.com>
Cool thanks.
What about just say I wanted the size of $hash{baz} => [ 0,1,2 ] ?
lawre...@hummer.not-here.net wrote:
> "jtbutler78@comcast.net" <jtbutler78@comcast.net> writes:
> > I have a hash with the values being arrays. How can I find the size of
> > these arrays?
> >
> > example:
> > $hash{$key} = [ 0, 1];
> > $hash{$key1} = [ 0, 1];
> > $hash{$key2} = [ 0, 1,2];
> > $hash{$key3} = [ 0];
> >
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Data::Dumper;
>
> my %hash = ( foo => [ 0,1 ] ,
> bar => [ 0,1 ] ,
> baz => [ 0,1,2 ],
> waldo => [ 0] );
>
> my $sum;
> $sum += @$_ for values %hash;
>
> print "total length = $sum\n";
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
> Computer software consists of only two components: ones and
> zeros, in roughly equal proportions. All that is required is to
> sort them into the correct order.
------------------------------
Date: 14 Jun 2006 11:48:56 -0700
From: "it_says_BALLS_on_your forehead" <simon.chao@fmr.com>
Subject: Re: size of anonymous array
Message-Id: <1150310936.568897.92500@g10g2000cwb.googlegroups.com>
jtbutler78@comcast.net wrote:
> I have a hash with the values being arrays. How can I find the size of
> these arrays?
>
> example:
> $hash{$key} = [ 0, 1];
> $hash{$key1} = [ 0, 1];
> $hash{$key2} = [ 0, 1,2];
> $hash{$key3} = [ 0];
use strict;
use warnings;
my %hash = (
one => [0],
two => [1,2],
three => [4,5,6],
);
map { my $size = @{$hash{$_}}; print "$_ => $size\n" } keys %hash;
------------------------------
Date: 14 Jun 2006 11:56:57 -0700
From: lawrence@hummer.not-here.net
Subject: Re: size of anonymous array
Message-Id: <873be7pnuu.fsf@hummer.i-did-not-set--mail-host-address--so-shoot-me>
"jtbutler78@comcast.net" <jtbutler78@comcast.net> writes:
> Cool thanks.
>
> What about just say I wanted the size of $hash{baz} => [ 0,1,2 ] ?
>
Any list evaluated in scalar context returns its size.
@$hash{baz} is the list ( 0, 1, 2 )
Therefore
my $size = @$hash{baz};
You can use scalar() to force scalar context in places where that is
needful.
print 'The array has ', scalar(@$hash{baz}), ' element(s)';
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer software consists of only two components: ones and
zeros, in roughly equal proportions. All that is required is to
sort them into the correct order.
------------------------------
Date: Wed, 14 Jun 2006 12:14:59 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: size of anonymous array
Message-Id: <140620061214596406%jgibson@mail.arc.nasa.gov>
In article <1150309923.250349.15280@f6g2000cwb.googlegroups.com>,
<"jtbutler78@comcast.net"> wrote:
> I have a hash with the values being arrays. How can I find the size of
> these arrays?
Actually, the values are _references_ to arrays.
>
> example:
> $hash{$key} = [ 0, 1];
> $hash{$key1} = [ 0, 1];
> $hash{$key2} = [ 0, 1,2];
> $hash{$key3} = [ 0];
$#{$hash{$key}} is the larget index.
@{$hash{$key}} in scalar context is the size.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: 14 Jun 2006 12:37:46 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: size of anonymous array
Message-Id: <1150313866.397726.26540@g10g2000cwb.googlegroups.com>
lawrence@hummer.not-here.net wrote:
> "jtbutler78@comcast.net" <jtbutler78@comcast.net> writes:
>
> > What about just say I wanted the size of $hash{baz} => [ 0,1,2 ] ?
>
> Any list evaluated in scalar context returns its size.
No. Any *array* evaluated in scalar context returns its size. A
"list" in scalar context doesn't exist. The comma-operator in scalar
context returns its right-most argument.
> @$hash{baz} is the list ( 0, 1, 2 )
No, it's not. @$hash{baz} is the same as @{$hash}{baz}, which is the
one-element slice of the hash %{$hash} containing the element 'baz'.
I'm guessing you meant @{$hash{$baz}}, which is the array referenced by
the hash value $hash{$baz}.
You need to re-read the dereferencing rules in
perldoc perlref
Even so, that would be the *array* containing the list (0, 1, 2). The
distinction is important. Please read:
perldoc -q difference
> Therefore
>
> my $size = @$hash{baz};
my $size = @{$hash{baz}};
> You can use scalar() to force scalar context in places where that is
> needful.
>
> print 'The array has ', scalar(@$hash{baz}), ' element(s)';
Or just use an operator that does force scalar context, instead of one
that gives list context:
print 'The array has ' . @{$hash{baz}} . ' element(s)';
Paul Lalli
------------------------------
Date: Wed, 14 Jun 2006 16:43:42 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: size of anonymous array
Message-Id: <slrne910oe.1kv.tadmc@magna.augustmail.com>
jtbutler78@comcast.net <jtbutler78@comcast.net> wrote:
> I have a hash with the values being arrays. How can I find the size of
> these arrays?
> example:
> $hash{$key} = [ 0, 1];
But using "Use Rule 1" from:
perldoc perlreftut
I like to do it in 3 steps:
my $size = @array; # pretend it is a plain array
my $size = @{ }; # replace the array's *name* with a block
my $size = @{ $hash{$key} }; # put something in the block that
# returns the right type of reference
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 14 Jun 2006 20:55:40 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e6pm2u$2pb$1@online.de>
Torben Ęgidius Mogensen schrieb:
> For example,
> if you have to code everything as natural numbers, untyped pure lambda
> calculus or S-expressions, there is a good chance that you can get
> nonsense past the compiler.
Also past peer review and/or debugging runs. And, most importantly, past
your own mental review processes.
Regards,
Jo
------------------------------
Date: Wed, 14 Jun 2006 21:04:34 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e6pmjl$4j5$1@online.de>
Raffael Cavallaro schrieb:
> On 2006-06-14 09:42:25 -0400, torbenm@app-1.diku.dk (Torben Ęgidius
> Mogensen) said:
>
>> It takes longer for the average
>> programmer to get the program working in the dynamically typed
>> language.
>
> Though I agree with much of your post I would say that many here find
> the opposite to be true - it takes us longer to get a program working in
> a statically typed language because we have to keep adding/changing
> things to get the compiler to stop complaining and actually compile and
> run
I think Torben was assuming a language with type inference. You write
only those type annotations that really carry meaning (and some people
let the compiler infer even these).
> a program which would be perfectly permissible in a dynamically
> typed language such as common lisp - for example - heterogeneous lists
> and forward references to as yet non-existent functions.
Um... heterogenous lists are not necessarily a sign of expressiveness.
The vast majority of cases can be transformed to homogenous lists
(though these might then contain closures or OO objects).
As to references to nonexistent functions - heck, I never missed these,
not even in languages without type inference :-)
I don't hold that they are a sign of *in*expressiveness either. They are
just typical of highly dynamic programming environments such as Lisp or
Smalltalk.
Regards,
Jo
------------------------------
Date: Wed, 14 Jun 2006 21:09:08 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e6pms6$59s$1@online.de>
Rob Thorpe schrieb:
>
> If a language can express constraints of one kind that is an increase
> in expressiveness.
Agreed.
> If a language requires constraint to be in one particular way thats a
> decrease in expressiveness.
Unless alternatives would be redundant.
Having redundant ways to express the same thing doesn't make a language
more or less expressive (but programs written in it become more
difficult to maintain).
> So I would say languages that can be statically typed and can be
> dynamically typed are the most expressive. Languages that require
> static typing or are dynamic but cannot express static typing are less
> expressive.
Note that this is a different definition of expressiveness.
(The term is very diffuse...)
I think Felleisen's paper defines something that should be termed
"conciseness".
Whether there's a way to express constraints or other static properties
of the software is something different. I don't have a good word for it,
but "expressiveness" covers too much for my taste to really fit.
Regards,
Jo
------------------------------
Date: Wed, 14 Jun 2006 22:18:03 +0200
From: Pascal Costanza <pc@p-cos.net>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <4fb97sF1if8l6U1@individual.net>
Torben Ęgidius Mogensen wrote:
> On a similar note, is a statically typed langauge more or less
> expressive than a dynamically typed language? Some would say less, as
> you can write programs in a dynamically typed language that you can't
> compile in a statically typed language (without a lot of encoding),
> whereas the converse isn't true.
It's important to get the levels right here: A programming language with
a rich static type system is more expressive at the type level, but less
expressive at the base level (for some useful notion of expressiveness ;).
> However, I think this is misleading,
> as it ignores the feedback issue: It takes longer for the average
> programmer to get the program working in the dynamically typed
> language.
This doesn't seem to capture what I hear from Haskell programmers who
say that it typically takes quite a while to convince the Haskell
compiler to accept their programs. (They perceive this to be worthwhile
because of some benefits wrt correctness they claim to get in return.)
Pascal
--
3rd European Lisp Workshop
July 3 - Nantes, France - co-located with ECOOP 2006
http://lisp-ecoop06.bknr.net/
------------------------------
Date: Wed, 14 Jun 2006 22:36:52 +0200
From: Pascal Bourguignon <pjb@informatimago.com>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <878xnzv5i3.fsf@thalassa.informatimago.com>
Joachim Durchholz <jo@durchholz.org> writes:
> Raffael Cavallaro schrieb:
>> a program which would be perfectly permissible in a dynamically
>> typed language such as common lisp - for example - heterogeneous
>> lists and forward references to as yet non-existent functions.
>
> Um... heterogenous lists are not necessarily a sign of
> expressiveness. The vast majority of cases can be transformed to
> homogenous lists (though these might then contain closures or OO
> objects).
In lisp, all lists are homogenous: lists of T.
--
__Pascal Bourguignon__ http://www.informatimago.com/
ADVISORY: There is an extremely small but nonzero chance that,
through a process known as "tunneling," this product may
spontaneously disappear from its present location and reappear at
any random place in the universe, including your neighbor's
domicile. The manufacturer will not be responsible for any damages
or inconveniences that may result.
------------------------------
Date: Wed, 14 Jun 2006 20:24:47 +0200
From: "wish" <wishmasterCUT@poczta.onet.pl>
Subject: XMLRPC::Lite
Message-Id: <e6pka5$7e0$1@atlantis.news.tpi.pl>
Hi,
I'm having trouble using XMLRPC::Lite module.
I am putting my XMLRPC modules using 'dispatch_to' method called at
...HTTP::Daemon class. The dispatch_to argument is the path to where my
modules are.
The problems, i've encountered are:
- cutting @INC table to only the path to my modules ("for security"..), what
makes those modules completely useless - at this time i'm restoring the @INC
from @lib::ORIG_INC but this makes it impossible to use any custom external
library locations
- blocking access to modules with shorter paths when calling those with long
names first time after server restart. For example calling "Sth.Sth.method"
which is translated into call "Sth::Sth::method" blocks access to
Sth::method.
Are there any usable resources with info about how to REALLY use this
module, not only print the 'hello world'? At the time i've found
"Programming Web Services With Perl" and about a dozen web pages but none of
those taught me what layout of the module files should be maintained to make
them work...:/
Please help :/...
wish80
------------------------------
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:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#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 V10 Issue 9298
***************************************