Re: Switch, Ranges and Memory
- From: tom@xxxxxxxxxxxxxx (Tom Phoenix)
- Date: Tue, 29 Aug 2006 17:05:18 -0700
On 8/29/06, Barron Snyder (CE CEN) <Barron.Snyder@xxxxxxxxxxxxxx> wrote:
For example, if I create a list like (123..456754), does it take up the
same amount of memory as if I actually entered all those in between
numbers?
Generally, yes.
I'm asking because I want to use ranges in a switch statement and they
are large ranges like the above. I don't think I can use >= in the case
section of the switch can I?
It depends. What programming language are you talking about? Perl
doesn't have case/switch statements, although there are some extension
modules that add that functionality. If you're using one of those
extension modules, you should check its documentation to see what it
allows.
case [4096..8191] { $block{"VoidItem"} = "Y";
Each of your cases seems to begin on a power-of-two. Would you be
really happy to discover the function int(log2($something))?
sub log2 { log($_[0]) / log(2) }
The Perl FAQ has an extensive list of ways to write switch/case
statements in Perl. Perhaps one of those will be useful, with or
without log2.
Hope this helps!
--Tom Phoenix
Stonehenge Perl Training
.
- References:
- Switch, Ranges and Memory
- From: Barron Snyder
- Switch, Ranges and Memory
- Prev by Date: Can't create 2d array in Perl
- Next by Date: Re: Can't create 2d array in Perl
- Previous by thread: Switch, Ranges and Memory
- Next by thread: Re: Switch, Ranges and Memory
- Index(es):
Relevant Pages
|