cvs commit: perlfaq perlfaq4.pod

[email protected]
Newsgroups perl.cvs.perlfaq
Message-ID <[email protected]>
cvsuser     02/02/24 01:18:57

  Modified:    .        perlfaq4.pod
  Log:
  -- How can I tell whether a certain element is contained in a list or array?
  
  * clear aggregates by assigning () rather than undef.
  
  * changed "associative array" to "hash"
  
  Revision  Changes    Path
  1.16      +4 -4      perlfaq/perlfaq4.pod
  
  Index: perlfaq4.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq4.pod,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -w -r1.15 -r1.16
  --- perlfaq4.pod	21 Feb 2002 14:48:01 -0000	1.15
  +++ perlfaq4.pod	24 Feb 2002 09:18:57 -0000	1.16
  @@ -1,6 +1,6 @@
   =head1 NAME
   
  -perlfaq4 - Data Manipulation ($Revision: 1.15 $, $Date: 2002/02/21 14:48:01 $)
  +perlfaq4 - Data Manipulation ($Revision: 1.16 $, $Date: 2002/02/24 09:18:57 $)
   
   =head1 DESCRIPTION
   
  @@ -1130,11 +1130,11 @@
   
   That being said, there are several ways to approach this.  If you
   are going to make this query many times over arbitrary string values,
  -the fastest way is probably to invert the original array and keep an
  -associative array lying about whose keys are the first array's values.
  +the fastest way is probably to invert the original array and maintain a
  +hash whose keys are the first array's values.
   
       @blues = qw/azure cerulean teal turquoise lapis-lazuli/;
  -    undef %is_blue;
  +    %is_blue = ();
       for (@blues) { $is_blue{$_} = 1 }
   
   Now you can check whether $is_blue{$some_color}.  It might have been a
  @@ -1144,7 +1144,7 @@
   array.  This kind of an array will take up less space:
   
       @primes = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31);
  -    undef @is_tiny_prime;
  +    @is_tiny_prime = ();
       for (@primes) { $is_tiny_prime[$_] = 1 }
       # or simply  @istiny_prime[@primes] = (1) x @primes;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.