How to convert Infix notation to postfix notation

S

spinoza1111

But multiple choice tests are a mistake as well, unless they are
psychological profile tests in womens' magazines that no-one with any sense
would take seriously.

Multiple choice tests are a reality, and should not be rejected
because they are "hard" or "contain errors". I now teach, among other
things, test preparation to Asian students who are systematically
discriminated against by American universities.

They don't have cushy jobs. They don't have Richard's leisure to
condemn the tests they must pass with high scores. Therefore I tell
them that it's not their concern if they find an error on a test.

I also tell them that the only answer they should mark should be the
best answer, and (1) there might be > 1 right answers (2) usually only
one correct answer and (3) in the case of an error in the test, the
best might not even be correct.

Nonetheless, if one has studied K & R, the Sparknotes is probably easy
because one (unless one's an autistic twerp) has learned two things in
any class, no matter how technical:

(1) The "right stuff"
(2) The favored interpretation

(2) is more important in English and other humanities but is even true
in mathematics. In the case of Sparknotes, the best answers reflect
what is usually taught and what, in practice, creates programmers who
can program, as opposed to programmers who (1) insist on always being
right and (2) start campaigns of personal destruction when their will
is thwarted.
The problem is that if a question is at all interesting it will have more
than one answer. Sure, you can ask, "which construct is portable?". However
the assumption that C bytes are 8 bits is probably more portable than the
assumption that a long is at least 32 bits. 8 bit bytes are so useful that
compiler writers fake them up even when the underlying hardware won't
support the reads, even though the standard doesn't require this. Whilst on
tiny systems int is sometimes 8 bits and long 16 bits, to encourage
programmers to use integers that fit in registers where possible. So to
answer a question about "portability" you need to explain the situation.
Which won't fit in atick box.

Excellent points, all of them.

If you want to be a computer scientist, then be a computer scientist:
if you want to be a programmer, be a programmer.
 
S

spinoza1111

Hmm.  You should hook up with Scott Nudds, I'm sure he'd appreciate your
insights into the merits of language design.

I don't think I find your argument persuasive.  I do not think there exists
a universally ideal language design; in fact, it seems to me that
domain-specific languages are a compelling choice for many applications.

I view languages as tools.  I expect to see a single unified language
about the time I expect to see a single unified woodworking tool, and
for about the same reasons.


Except you've never shown this.  You've asserted that it fails to conform
to your expectations, and that you think this is a mistake, but you've not
exactly proven your point.

Are you seriously defending a()+b() reordering, not reordering a()||b
(), and backwards parameters? If so you're not qualified to speak on
programming languages in my opinion.
That's a whole lot of very pretty rhetoric, but again, you have to prove
your point before arguing further from it.


This isn't a sentence, but if it were, I'd bet it would be a stupid

Typo. Change in to is.
one.  You seem to have omitted a clause, though.  Anyway, don't worry,
I'm almost certainly more famous for expertise in Bourne shell than
I am for expertise in C now.  (And if you want to see a language which
is chock full of astounding mistakes, Bourne shell is a true marvel
of the art.  It isn't used because it's an incredibly well-designed
language, but because it's extremely widely available and fairly
flexible, and we've learned how to overcome most of the weaknesses.)


You know, it's a shame that we wasted thousands and thousands of years
of peoples' time researching computer science and language design when we
coulda just watched a superbowl ad and gotten the real answer.

Tell you what, just as a quick sanity check:

The one programming language that can be used by everyone:
* Should have a way to express explicit invocation of specific machine
  instructions, yes/no?
No.

* Should completely abstract away memory management so there's no such
  things as pointers, yes/no?

What part of safe v unsafe mode don't you understand?
* Should be designed for "intelligent" people rather than "autistic twerps",
  yes/no?

A big fat YES
* Should be accessible to people who are not particularly intelligent,
  yes/no?

A big fat NO, and intelligence is NOT measured by IQ score. It's
primarily measured (for example on the modern SAT, even though this
doesn't purport to measure intelligence) by the ability to express
oneself accurately in one's native language.
 
O

osmium

spinoza1111 said:
Furthermore, the idea that computer languages are even distinct is
absurd. That they are is a historical accident, caused by the large
number of errors made in language design in the early days.

AFAICT, you claim involvement dating to the mid 50's, so this should be easy
for you. I'd like to see your list of the large number of errors in the
design of Algol 60. As a matter of fact there *was* a very good language
available early on, but it never caught on in the USA; and the US, IBM and
Microsoft has been dominant in the computer field for a very long time.
 
N

Nick Keighley

i have a string as (a+b)+8-(c/d) in Infix form.

how can i convert it to postfix form using C language,,,????

have you looked at Dijkstra's Shunting-yard algorithm? Probably what
your instructor meant you to do rather than building a parser.
 
S

Seebs

Dik has documented the fact that Algol's evaluation order was
nondeterministic. We now know that this is a mistake, since we now
know how to optimize.

You keep making this claim, but you never actually establish a chain of
reasoning from undisputed facts which has this as a conclusion.

-s
 
S

Seebs

You see, in practically every post you mention my "errors" in the same
way people prefer to repeat "the errors of Schildt" as if this cite of
a cite makes the errors more numerous.

No one seems to be doing any such thing, in either case.

-s
 
S

Seebs

Multiple choice tests are a reality, and should not be rejected
because they are "hard" or "contain errors".

In general, multiple choice tests are less good than other tests, but
are favored anyway because of the possible for automatic scoring. In
short, they make compromises in one attribute to score well in another.
A familiar theme; I'm surprised you aren't out campaigning against
these "mistakes."
I also tell them that the only answer they should mark should be the
best answer, and (1) there might be > 1 right answers (2) usually only
one correct answer and (3) in the case of an error in the test, the
best might not even be correct.

Seems right.
Nonetheless, if one has studied K & R, the Sparknotes is probably easy
because one (unless one's an autistic twerp) has learned two things in
any class, no matter how technical:

(1) The "right stuff"
(2) The favored interpretation

That would work if they didn't have questions in which they choose an
answer which is unambiguously neither correct nor a favored interpretation.
(2) is more important in English and other humanities but is even true
in mathematics. In the case of Sparknotes, the best answers reflect
what is usually taught and what, in practice, creates programmers who
can program, as opposed to programmers who (1) insist on always being
right and (2) start campaigns of personal destruction when their will
is thwarted.

Actually, people who go with "what is usually taught" rather than what works
do about as well as a hypothetical structural engineer who goes with common
fashion rather than actual functionality.

-s
 
S

Seebs

Are you seriously defending a()+b() reordering, not reordering a()||b
(), and backwards parameters?

Why, yes.
If so you're not qualified to speak on
programming languages in my opinion.

This is exactly my point. Read that quoted paragraph again.
"You've asserted that it fails to conform to your expectations,
and that you think this is a mistake, but you've not exactly proven
your point."

You haven't actually made any argument for this except a bald assertion
that "intelligent" people would expect it. You haven't established that
this is true. You haven't established that, if it is true, it should
be a significant component of language design. You haven't established
that it trumps other points.

I gave you a clear and concrete reason for which || should not be reordered,
which does not apply to +, but you seem unable to actually respond to or
make technical arguments. Ironically, despite your huge wall-of-text
complaints about other people making things personal, you use your insult
of the week about ten times as often as you make actual technical statements.

We've established that you dislike me, but you haven't shown that this is
a sound basis for a change in the design of programming languages.
Typo. Change in to is.
Figured.

Well. Congratulations, you've proposed that everyone use a language
that can't actually implement operating systems on most currently-available
hardware.

You fail at language design. Thanks for playing.
What part of safe v unsafe mode don't you understand?

Hmm. I'd guess that'd be the part where I've never heard of them?
A big fat YES
Expected.
A big fat NO,

Then it can't be used by everyone, because the majority of people are
not partiicularly intelligent.
and intelligence is NOT measured by IQ score.

Not having one, I would hardly claim that it is. :p
It's
primarily measured (for example on the modern SAT, even though this
doesn't purport to measure intelligence) by the ability to express
oneself accurately in one's native language.

Indeed. Which is interesting, because you suck at that.

Well, that sounds nice on paper, but turns out to pretty much suck for anyone
who wants battery life.

Also, and this is merely a technical point, I'm sure...

How exactly is your language supposed to be implemented? It can't be
implemented in itself. We need something that produces machine-specific
instructions, at least for the forseeable future, to allow chips to run
code. So that something else must be used to implement your language,
which means we can't have a single language used by everybody.

Please think these ideas through for five minutes or so before suggesting
them, 'k?

-s
 
O

osmium

spinoza1111 said:
Dik has documented the fact that Algol's evaluation order was
nondeterministic. We now know that this is a mistake, since we now
know how to optimize.

Now I know what you consider a "large number": one. That casts your
observations in a different light.
 
S

Seebs

Seebs said:
I'll just give you my favorite:

After this code executes

int arr[10];
int i;
i = &arr[9] - arr;

what is the value of i?
(A) 8
(B) 9
(C) 10
(D) Won't compile
Go ahead, guess what their answer is. Guess what mine was. And guess
what my compiler says if I try it. :) (Hint: The last two are both
the correct answer. Theirs isn't.)
Seebs - As my new hero contra spino I tend to support you. But looking
at your example I saw 9 - 0 which is 9. I wrote a little program (below)
and compiled it with each of my 4 C compilers. All 4 compiled it without
diags and when run, all 4 report the value of i as 9. What did I miss?

You missed nothing. The sparknotes people, however, feel that the answer
is (C) 10.

-s
 
S

spinoza1111

Oops, my bad.  There is an 'is' missing.  I'm with the wide boy
on this one, though - it's a typo.

Richard Harter, [email protected]://home.tiac.net/~cri,http://www.varinoma.com
Kafka wasn't an author;
Kafka was a prophet!

Let me all save you guys a lot of trouble:

People whose main claim to expertise IS C should be sent to re-
The subject is people subsetted by those whose main claim is C. The
main verb is modal: "should be sent". The indirect object is "re-
education camps". This should be done "on the model of ", which is an
adverbial.
 
K

Keith Thompson

Richard Heathfield said:
17. (d) is undoubtedly the intended answer. In C, the value of NULL is
always 0. Its type is either int or void *.
[...]

Tiny quibble: The type of NULL can be void* or any integer type.
For example:
#define NULL 0ULL
is legal.

(Actually, I'm not certain it can be an integer type narrower than
int.)
 
B

Ben Bacarisse

Malcolm McLean said:
Computer code frquently contains errors which are simple lapses of logic. To
the layman, these might seem to be the result of inexperience. Actually even
highly-qualified programmers of twenty years' or more experience make such
errors, and not infrequently either.

True. Spiniza1111 may be highly qualified and very experienced but
the grammar he posted was wrong and then the code that purports to
parse the corrected grammar did not do so. These may be due to simple
lapses of logic, but Spiniza1111 was suggesting that the code be used
as a model to follow. I thought (maybe wrongly) that it was worth
discouraging that use.
To allude to a bug is a very bad way of making a bug report.

I am not making a bug report. I don't want to facilitate
Spiniza1111's desire to have an off-topic discussion of his C# code
here. Saying nothing may have been preferable.

<snip>
 
S

spinoza1111

True.  Spiniza1111 may be highly qualified and very experienced but
the grammar he posted was wrong and then the code that purports to
parse the corrected grammar did not do so.  These may be due to simple
lapses of logic, but Spiniza1111 was suggesting that the code be used
as a model to follow.  I thought (maybe wrongly) that it was worth
discouraging that use.

Ben, do you make the above claim about the most recent version, or are
you deliberately using past tense in order to dishonestly persist in a
claim? If so, you are indeed an "asshole" after all.
 
S

spinoza1111

In general, multiple choice tests are less good than other tests, but
are favored anyway because of the possible for automatic scoring.  In
short, they make compromises in one attribute to score well in another.
A familiar theme; I'm surprised you aren't out campaigning against
these "mistakes."


Seems right.



That would work if they didn't have questions in which they choose an
answer which is unambiguously neither correct nor a favored interpretation.


Actually, people who go with "what is usually taught" rather than what works
do about as well as a hypothetical structural engineer who goes with common
fashion rather than actual functionality.

Programmers are not engineers. Engineers have legal certification
procedures which programmers do not have. Programmers compare
themselves to engineers, but the best coder here, Bacarisse, prefers
at the crisis to stop reviewing code and make assertions about the
first version of the C Sharp parsing solution to Malcolm without
acknowledging whether or not the third version addresses his concerns.
Engineers don't do this because their limited job security provides
them the self-confidence and self-esteem of adults, a self-confidence
and self-esteem that is lacking in nearly every programmer I have
known.

At the Glosten Associates in Seattle in 1986, I wrote the first
version of their very successful GSSP graphical program for ship
stability. I worked with men certified as Ocean Engineers and I was
very impressed by their decency. Years later, during the Iraq war, I
met them again at a shipping conference and was also impressed to
learn that the company was not trying to get contracts in Iraq because
most of its employees and its principals felt this to be folly. This
is what integrity looks like. It's not trying to weasel out of your
responsiblities to decency by claiming a fashionable disease such as
autism.

I posted a C Sharp "prototype" here in answer to the OP's question in
order to back up my claim that the problem of converting infix to
Polish can be solved by a formal grammar approach. Bacarisse asserted
in public without proof that the prototype was broken despite also
implying that he didn't know C Sharp.

Because I respect his coding and analysis skills I asked for further
comment. I received private email which indicated that, despite
Bacarisse's claim that he didn't know C Sharp, he'd nonetheless ran
the code, using a C Sharp system, possibly free .Net "Express".

He found several problems. All but one I'd found independent of him
within 24 hours of posting the code, and they were caused by missing
bounds checks which I'd already added. The last was failure to emit an
error report when parentheses were unbalanced and this I fixed in the
third version.

Whenever someone uses an approach, or here, a closely related
programming language meant to fix C, that others don't feel qualified
to work with, it's "off-topic". But the politics of personal
destruction are always on-topic, and I shall at will from now on start
using words like "asshole" to describe people who think they are being
cute when they engage in these politics.

I have yet to see Richard Heathfield or Peter Seebach simulate what
computer science teachers and teachers of programming have to do in
the classroom. This is write pseudo or real code on the board and
explain it. Neither seem capable of posting other than canned replies
and neither are willing to take the risk. Only Keith Thompson has the
combination of technical integrity and courage to do so.

I believe it's possible for an intelligent programmer to intelligently
comment about reasonably clear code in a language HE DOES NOT KNOW,
and I believe that for the same reason as in the traditional
structured walkthough comments from all are welcome, people here
should have the courage to step outside their comfort zones and study
non-C code that's germane to the issue. The problem is that little
coders are desparately afraid to do so, and prefer being Snidely
Snively to being men.

In my very limited spare time I am converting my little parser to C to
RElearn more about C in order to better defend Schildt, with all of
his flaws, because I think collegiality and decency are far more
important than being a cute little asshole of a computer programmer,
who's used, in our society, to create wealth for the wealthy and then
thrown aside at the age of 40. When I have something I will post it to
this thread.

When will you people grow up? Hopefully before I have to become a C
expert for the second time in my life!
 
S

spinoza1111

True.  Spiniza1111 may be highly qualified and very experienced but
the grammar he posted was wrong and then the code that purports to

The first version was wrong.
parse the corrected grammar did not do so.  These may be due to simple

The first version didn't test out of bounds in all cases. The second
version failed to flag unbalanced parentheses. Both versions were
instrumented with far more literate error reports and far more
thorough test cases than 99% of the code posted here, and little
enough new code is ever posted, even in C, because people prefer being
assholes.

The third version addresses all your concerns.

Stop being an asshole.
 
B

Ben Bacarisse

spinoza1111 said:
Ben, do you make the above claim about the most recent version,
No.

or are
you deliberately using past tense in order to dishonestly persist in a
claim?

I used the past tense to talk about what I had said because that is
what Malcolm commented on.

<snip>
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top