Re: Accessing Array Elements within [if-else]



On Feb 8, 7:25 pm, Neil Madden <n...@xxxxxxxxxxxxx> wrote:
slebet...@xxxxxxxxx wrote:
On Feb 8, 11:01 am, "SuNnY" <esu...@xxxxxxxxx> wrote:
if {$Counter==0} {
for {set i 0} {$i<=$Counter} {incr i} {

This piece of code is is exactly equivalent to:

set i 0

That's not true -- the condition of the [for] is checked after the
iteration, so it will still do one loop (i.e., Port(0) should exist):

Well, it IS true since doing exactly one loop means you can do it
without a for loop.

% for {set i 0} {$i <= 0} {incr i} { puts "i = $i" }

What I was saying before was, your code is exactly equivalent to:

set i 0; puts "i = $i"

see, you can remove the for loop surrounding your { puts "i = $i" }.

.



Relevant Pages

  • Yow! LOOP macros are LOOPY!
    ... By relying entirely on procedure calls to express iteration, ... to but cleaner than C's FOR loop. ... other macros going around at the time other than MacLisp's ... (bind (vi (vector-ref v i))) ...
    (comp.lang.scheme)
  • Re: Performance: Iterating a vector in a loop..
    ... > But he was saying its slow because .beginand .endare called every ... > loop. ... > I know that the function is called every iteration, ... > any speed hits when doing that, or, if it would be better to re-write the ...
    (microsoft.public.vc.language)
  • Re: Polling, Interrupts, DMA, Synchronous, Asynchronous I/O Definitions
    ... the terminology is less useful than it might be. ... though a "message loop" could arguably be claimed to be ... considering in a particular iteration but what is true for _ALL_ ... watching the "polling" version eating up every single CPU cycle ...
    (alt.lang.asm)
  • Re: Histogram of character frequencies
    ... generated object code may simply be a loop in which elements are ... believe any C compiler anywhere would reject it. ... On the first iteration of the loop you test the end of file indicator ...
    (comp.lang.c)
  • Re: Random number help
    ... is used to generate cooccurance matrix for each iteration of for loop. ... disp('the sample co-occurance matrix is as follows');% GIVING SAME ...
    (comp.soft-sys.matlab)