Sujet : Re: while(T[l]<p & l<=r)
De : fir (at) *nospam* grunge.pl (fir)
Groupes : comp.lang.cDate : 03. Apr 2024, 15:35:42
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <uujpfv$3ulr5$1@i2pn2.org>
References : 1 2
User-Agent : Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
Peter 'Shaggy' Haywood wrote:
Groovy hepcat fir was jivin' in comp.lang.c on Wed, 27 Mar 2024 10:35
pm. It's a cool scene! Dig it.
>
tell me, is while(T[l]<p & l<=r) the same as while((T[l]<p)&&(l<=r))
i was unable ro remember that
>
You're forgetting that && is a so-called "short circuit" operator. If
the left operand is false, then the right operand is not evaluated.
This makes little difference in this particular case; but what if you
had something like this instead?
>
while(some_function() < p && some_other_function() <= r)
>
Here some_other_function() will not be called if the some_function()
call returns a value >= p.
>
okay, good point, need to remember that - but anyway there is a wide aspect of usecases (roughly 100 procent of mine if im not wrong where
i can replace those poor && and || by really good loking & and |