alternative if syntax

O

optimistx

Osmo said:
In fact, TL's response was not only civil, but also cordial.

RTFM.

Your being an anonymous/nicknamed, Google
Groups, clueless newbie, nothing more was to be expected. FOAD.

PLONK
 
O

Osmo Saarikumpu

optimistx kirjoitti:

What is wrong with reading the fine manual? Let me quote the whole
context to make it clear:

"You're welcome, but please read the FAQ now, and ultimately RTFM."
^^^^^^^ ^^^^^^
The "you are welcome" is a polite response to a thanks. Please is a
civil request showing regard for others. I'd say that all the
bitterness, sourness and unfriendliness of the above tone is in the
touchy eye of the beholder.
Your being an anonymous/nicknamed,

There's a clue for you too.
Google
Groups, clueless newbie, nothing more was to be expected. FOAD.

That was another message, a response to an undeserved and unjust
personal attack. As the saying goes: ingratitude is the world's wage.
 
T

Thomas 'PointedEars' Lahn

Osmo said:
optimistx kirjoitti:

There's a clue for you too.


That was another message, a response to an undeserved and unjust
personal attack.

And it has been cancelled, and removed from the GG archives long since.

Your trying to support me is appreciated, but it is probably better not to
waste time with feeding the troll. Remember: Never argue with an idiot;
they drag you down to their level, then beat you with experience :)


Regards,

PointedEars
 
J

Jorge

Hi,
I came across this line of code in a book. It appears to use the
alternative if syntax, but it doesn't quite make sense to me:

res += (i * j) % 8 ? " " : "*";

where res is a string variable, and i and j are number variables (i
increments from 1 to 7 and j increments from 1 to 15).

What's confusing me is that I thought the expression preceding the ?
had to be a conditional (i.e., true or false) statement in order for
the computer to choose between " " and "*". But (i * j) % 8 isn't a
conditional. It just evaluates to a number. So how is the choice made
between " " and "*"?

Thank you,

The truly "alternative" if syntax is :)

res += ( ((i * j) % 8) && " " ) || "*";
 
T

The Natural Philosopher

Jorge said:
The truly "alternative" if syntax is :)

res += ( ((i * j) % 8) && " " ) || "*";
Cute, and getting cuter...

Hey Jorge, set up a call table in an array


so that depending on the index sent, a different function is called..


NO CASE statements allowed! Nor if then else.
 
T

The Natural Philosopher

Jorge said:
Cute, and getting cuter...

Hey Jorge, set up a call table in an array

Yeah ! You're right ! I forgot that one !

a= [" ", "*"];
res+= a[!((i * j) % 8)];

:)
Better, but no banana

given
function return_star()
{
return "*";
}
f8uncton return_blamk()
{
return " ";
}

now set up an array and a function that calls the correct one by
indexing off an array.
 
J

Jorge

Yeah ! You're right ! I forgot that one !
a= [" ", "*"];
res+= a[!((i * j) % 8)];

Better, but no banana

given
function return_star()
{
return "*";}

f8uncton return_blamk()
{
return " ";

}

now set up an array and a function that calls the correct one by
indexing off an array.

That's the same as above, just put functions into the array to have
them called afterwards:

a= [fBlank, fStar];
res+= a[!((i * j) % 8)]();
 
S

SAM

Le 10/20/09 11:05 PM, Jorge a écrit :
Jorge said:
On Oct 20, 10:40 pm, The Natural Philosopher <[email protected]>
wrote:
Jorge wrote:
The truly "alternative" if syntax is :)
res += ( ((i * j) % 8) && " " ) || "*";
Cute, and getting cuter...
Hey Jorge, set up a call table in an array
Yeah ! You're right ! I forgot that one !
a= [" ", "*"];
res+= a[!((i * j) % 8)];
:)
Better, but no banana

given
function return_star()
{
return "*";}

f8uncton return_blamk()
{
return " ";

}

now set up an array and a function that calls the correct one by
indexing off an array.

That's the same as above, just put functions into the array to have
them called afterwards:

a= [fBlank, fStar];
res+= a[!((i * j) % 8)]();

? ? ?

javascript:b=function(){return'blank'};c=function(){return'star'};a=[b,c];alert(a[!(250.23*2)%8]());
javascript:b=function(){return'blank'};c=function(){return'star'};a=[b,c];alert(a[!('z'*2)%8]());


javascript:b=function(){return'blank'};c=function(){return'star'};a=[b,c];alert((250.23*2)%8);alert(!((250.23*2)%8));alert(a[!((250.23*2)%8)]());
 
G

graderex

optimistx kirjoitti:


What exactly was so "unfriendly" or "crude" as the OP put it? I could
not have responded more civilly even if I had three weeks to practice.
In fact, TL's response was not only civil, but also cordial. Go ahead,
read it, parse it and get the correct returned value.

Simply, he made the OP (which may or may not be myself ;) feel like he
didn't have a right to ask the question. What he was saying in so many
words was, "Don't bother me with your stupid question. Read the manual
and figure it out for yourself." (except he was ruder). OK, fine. But
if you feel that way, why respond at all? It's much *quicker* and
*easier* to just ignore my question entirely then to get into a long-
winded answer (that went *way* beyond what I asked, by the way), and
then insult me for asking it!!! And he calls me (err... the OP) an
idiot!
 
G

graderex

 Your being an anonymous/nicknamed, Google
Groups, clueless newbie, nothing more was to be expected.  FOAD.

A couple of days of civil discussion, then suddenly the trolls chime
in with their vile two cents. Tell me, Where does your derision for
newbies come from? Maybe you're just a closet newbie, expert-wannabee
yourself? Whatever you are, I sure hope you're not a teacher by
profession. I could just picture it: the kids who don't get everything
they read perfectly the first time are taken out to the yard and given
100 lashes. If Mr. Optimistx is in a particularly cranky mood, poor
old student is told to FOAD, then stoned to death.

Go right ahead. In case you hadn't noticed, email addresses and Google
accounts are pretty easy to come by ;)
 
G

graderex

optimistx kirjoitti:
What is wrong with reading the fine manual?

Don't give me your bullshit spin. Nice substitution on the "f" there.
Here's an interesting quote from the Ubuntu forums:

If you wish to remind a user to use search tools or other resources
when they have asked a question you feel is basic or common, please be
very polite. Any replies for help that contain language disrespectful
towards the user asking the question, i.e. "STFU" or "RTFM" are
unacceptable and will not be tolerated.
—Ubuntu Forums
Let me quote the whole
context to make it clear:

"You're welcome, but please read the FAQ now, and ultimately RTFM."
         ^^^^^^^      ^^^^^^
The "you are welcome" is a polite response to a thanks. Please is a
civil request showing regard for others.
^^^^^^^^^^^^^^^^^^^^^^^^^
And this is you being an elitist, condescending a-hole.

I'd say that all the
bitterness, sourness and unfriendliness of the above tone is in the
touchy eye of the beholder.

Nice try Freud. But I'd say that RTFM speaks for itself. And if you
agree with and condone Optimistix's vile post, I'd say you're the
bitter, sour, and unfriendly one.
As the saying goes: ingratitude is the world's wage.

Look at my original reply to rf (the first poster who answered my
question). See the phrase "Thank you for your helpful reply." That's
called gratitude. PointedEars would have gotten a similar response, if
only he'd refrained from leaving out his last remark.
 
J

Jorge

Le 10/20/09 11:05 PM, Jorge a écrit :




Jorge wrote:
On Oct 20, 10:40 pm, The Natural Philosopher <[email protected]>
wrote:
Jorge wrote:
The truly "alternative" if syntax is :)
res += (  ((i * j) % 8) && " "  ) || "*";
Cute, and getting cuter...
Hey Jorge, set up a call table in an array
Yeah ! You're right ! I forgot that one !
a= [" ", "*"];
res+= a[!((i * j) % 8)];
:)
--
Jorge.
Better, but no banana
given
function return_star()
{
return "*";}
f8uncton return_blamk()
{
return " ";
}
now set up an array and a function that calls the correct one by
indexing off an array.
That's the same as above, just put functions into the array to have
them called afterwards:
a= [fBlank, fStar];
res+= a[!((i * j) % 8)]();

? ? ?

javascript:b=function(){return'blank'};c=function(){return'star'};a=[b,c];a lert(a[!(250.23*2)%8]());
javascript:b=function(){return'blank'};c=function(){return'star'};a=[b,c];a lert(a[!('z'*2)%8]());

javascript:b=function(){return'blank'};c=function(){return'star'};a=[b,c];a lert((250.23*2)%8);alert(!((250.23*2)%8));alert(a[!((250.23*2)%8)]());


Oh yes, I see, a + is needed in front of the !...

b=function(){return'blank'};
c=function(){return'star'};
a=[b,c];
alert(a[+!(((250.23*2))%8)]());
alert(a[+!((64*27)%8)]());
 
G

Gregor Kofler

graderex meinte:
Don't give me your bullshit spin. Nice substitution on the "f" there.
Here's an interesting quote from the Ubuntu forums:

[snip]

Who cares? This is *usenet*, not some ubuntu forum.

Gregor
 
G

Gregor Kofler

graderex meinte:
Simply, he made the OP (which may or may not be myself ;)

What's this nymshifting good for - except that you look like a full
blown troll now? The alt.* groups are elsewhere.

Gregor
 
G

graderex

graderex meinte:
Don't give me your bullshit spin. Nice substitution on the "f" there.
Here's an interesting quote from the Ubuntu forums:

[snip]

Who cares? This is *usenet*, not some ubuntu forum.

Gregor

Oh, so if you're a *usenet* person, then it's OK to behave like an
uncivilized a-hole? Ah ha, thanks for setting me straight.
 
G

graderex

graderex meinte:


What's this nymshifting good for - except that you look like a full
blown troll now? The alt.* groups are elsewhere.

Gregor

--http://www.gregorkofler.com

No, trolls are people who attack you with lame arguments and foul
language, then hang up on you and block your number so you don't have
a chance to respond. (hence the necessity of "nymshifting")
 
G

Gregor Kofler

graderex meinte:
graderex meinte:
optimistx kirjoitti:
What is wrong with reading the fine manual?
Don't give me your bullshit spin. Nice substitution on the "f" there.
Here's an interesting quote from the Ubuntu forums:
[snip]

Who cares? This is *usenet*, not some ubuntu forum.

Gregor

Oh, so if you're a *usenet* person, then it's OK to behave like an
uncivilized a-hole? Ah ha, thanks for setting me straight.

Ok. To get that right: After a lengthy explanation about ternary
operators, the modulo operator, things that might be considered, etc.
somebody states "You're welcome, but please read the FAQ now, and
ultimately RTFM."

You rate this person as an "uncivilized asshole"? *Very* enlightening.

I suppose you rather get lost and stick to your cozy ubuntu forums.
Definitely. Cause you have no idea how abrasive it can be here. And the
constant nymshifting might be troubling.

Gregor
 
D

Dr J R Stockton

Tue said:
It doesn't take long for people to figure out how unfriendly
PointedEars is. It's weird isn't it, if he only knew how to communicate
in a friendly manner he might well become a hero around here. Instead
though, despite his obvious knowledge, he makes enemies here every day.

<FAQENTRY> It's time that there was a FAQ section about Pointy. His
routine insistence on reading the FAQ would then become even more
beneficial.

Perhaps he should be cross-posted into de.sci.medizin.psychiatrie, which
has activity; or de.sci.*.
 
T

The Natural Philosopher

Jorge said:
Le 10/20/09 11:05 PM, Jorge a écrit :




On Oct 20, 10:55 pm, The Natural Philosopher <[email protected]>
wrote:
Jorge wrote:
On Oct 20, 10:40 pm, The Natural Philosopher <[email protected]>
wrote:
Jorge wrote:
The truly "alternative" if syntax is :)
res += ( ((i * j) % 8) && " " ) || "*";
Cute, and getting cuter...
Hey Jorge, set up a call table in an array
Yeah ! You're right ! I forgot that one !
a= [" ", "*"];
res+= a[!((i * j) % 8)];
:)
--
Jorge.
Better, but no banana
given
function return_star()
{
return "*";}
f8uncton return_blamk()
{
return " ";
}
now set up an array and a function that calls the correct one by
indexing off an array.
That's the same as above, just put functions into the array to have
them called afterwards:
a= [fBlank, fStar];
res+= a[!((i * j) % 8)]();
? ? ?

javascript:b=function(){return'blank'};c=function(){return'star'};a=[b,c];a lert(a[!(250.23*2)%8]());
javascript:b=function(){return'blank'};c=function(){return'star'};a=[b,c];a lert(a[!('z'*2)%8]());

javascript:b=function(){return'blank'};c=function(){return'star'};a=[b,c];a lert((250.23*2)%8);alert(!((250.23*2)%8));alert(a[!((250.23*2)%8)]());


Oh yes, I see, a + is needed in front of the !...

b=function(){return'blank'};
c=function(){return'star'};
a=[b,c];
alert(a[+!(((250.23*2))%8)]());
alert(a[+!((64*27)%8)]());

I am truly impressed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,084
Messages
2,570,596
Members
47,217
Latest member
GuadalupeE

Latest Threads

Top