develooper Front page | | Postings from September 2000

Re: RFC 231 (v1) Data: Multi-dimensional arrays/hashes and slices

Thread Previous | Thread Next
Jeremy Howard
September 22, 2000 16:01
Re: RFC 231 (v1) Data: Multi-dimensional arrays/hashes and slices
Message ID:
Karl Glazebrook wrote:
> Ilya Zakharevich wrote:
> > You are trading a frequently used shortcut @a == 1 + $#a for a
> > rarely-used-but-beautiful/intuitive semantic.  I'm not sure it is a win.
> It's now boiling down to a matter of opinion and we'll have to agree to
> differ. Of course I use array arithmetic all the time as a heavy PDL
> user.
It's not just for number-crunchers either. Array notation greatly simplifies
many frequently used operations. For instance (from RFC 82):

  @people = ('adam', 'eve ', 'bob ');
  @scores = (7,9,5);          # Score for each person
  @histogram = '#' x @scores; # Returns ('xxxxxxx','xxxxxxxxx','xxxxx')
  print join("\n", @people . ' ' . @histogram);

  adam xxxxxxx
  eve  xxxxxxxxx
  bob  xxxxx

Array notation is not 'rarely used' in languages that support it--in fact,
operations are applied to arrays and lists at least as often as scalars in
most code I see written for Mathematica, J, PDL, and so forth.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About