Stuart White wrote:

> > >(2) Joseph
> stuart>I thought this one was a joke.

Twas.  The again it wasn't.  Like Uncle Walt I like to cntradict myself.  I
actually did mean what I said, both about my impression that you were letting
yourself get caught up in codishness, and that the primary purpose of this
script was to produce rolling screen graphics.  Make yourself a cup of tea, sit
back and run it again--without thinking about anything technical.  I enjoy the
way theforms move across the sreen as the iterations progress.

It was also designed as open-ended.  This is somethng to be aware of anytime you
see a constant value in the control expression of a loop.  Unless there is an
internal break [last; in Perl] condition, the procedure is set for continuous
operation.

As an exercise, you might see what adaptations would be required to provide more
sane output, or to set a limiting condition, which brings us to...

>

> This one is a bit confusing.
> $max=shift||17393;

Very standard, actually [though I would prefer seeing it with some space around
the asignment and alternative operators.

$max takes the value of shift and the statement returns if their is at least one
argument and the argument evaluates true.  If their are no arguments, or the
first argument is 0, the empty string '', or undef, the alternation proceeds to
evaluate the right operator, providing the default value of 17393.
This technique uses the short-circuit evaluation of the || operator.  Since the
value is true if either operaor is true, it will return as soon as it finds one
true value, without evaluating the right operator.  The converse process can be
used with the && operator.  If it finds a single false value, it will return
false without evaluating further.  This seems to be used less frequently than
with the ||, though.

Joseph



>
> stuart>I thought shift was to remove an element from
> stuart>the beginning of an array, but it's being used
> stuart>in scalar context here.  Why?  And what is it
> stuart>doing?
>
>  %notprime=();
> > @prime=();
> >
> > for $n (2..$max){
> stuart>this makes me think that you were somehow
> stuart>assigning a number to $max above.  But where
> stuart>does 17393 come in?  Why not 17394, or 18000?
>
> >       unless($notprime{$n}){
> >               push @prime,$n;
> >               $notprime{$_*$n}=1 for 2..$max/$n;
> stuart>I'm not sure I understand this line directly
> stuart>above.  What I think it says is that it is
> stuart>accessing the value within the %notprime hash
> stuart>where the key equals the last inputted number
> stuart>which I suppose is $n and $_ if $n was pushed
> stuart>onto @prime, but just $_ if $n was not pushed
> stuart>onto @prime.  I don't get the "=1" part
> stuart>though.  What is that doing?  I'm assuming that
> stuart>is a for loop there that is working like a
> stuart>foreach loop?  but I'm not quite sure what it's
> stuart>doing.
>
> > Cheers.
> > David
> >
> >
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Search - Find what you’re looking for faster
> http://search.yahoo.com
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to