-
Aug 6th, 2011, 07:13 AM
#1
Thread Starter
Member
PREFIX TO POSTFIX help
Are you familiar with prefix and postfix? I just wonder how to solve it especially if the expression is too long. Please help me. thanks.
-
Aug 6th, 2011, 09:12 AM
#2
Re: PREFIX TO POSTFIX help
you need to provide us with more details on what you're trying to do. Give an example. Your question is too vague for anyone to understand what you're asking.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Aug 6th, 2011, 09:36 AM
#3
Re: PREFIX TO POSTFIX help
As in:
Prefix
and
Postfix
What about
Infix?
-
Aug 6th, 2011, 12:28 PM
#4
Re: PREFIX TO POSTFIX help
I think the OP is wanting to convert Prefix notation to Postfix notation. I don't know how to do that; I've seen examples on converting Infix to Postfix (Shunting yard algorithm anybody?), but I agree with stanav: We need more details to understand what you're really trying to do.
-
Aug 7th, 2011, 07:08 AM
#5
Thread Starter
Member
Re: PREFIX TO POSTFIX help
Here is the example:
Input: 5 * 3 + 6 / 2
Output: 5 3 * 6 2 / +
I just wonder how to solve it in VB.NET especially if the expression is too long..
-
Aug 7th, 2011, 08:48 AM
#6
Re: PREFIX TO POSTFIX help
Originally Posted by formlesstree4
I think the OP is wanting to convert Prefix notation to Postfix notation. I don't know how to do that; I've seen examples on converting Infix to Postfix (Shunting yard algorithm anybody?), but I agree with stanav: We need more details to understand what you're really trying to do.
They went somewhere else for the answer, and what they were looking for was the shunting yard.
http://www.dreamincode.net/forums/to...-postfix-help/
-
Aug 14th, 2011, 01:06 AM
#7
Thread Starter
Member
Re: PREFIX TO POSTFIX help
-
Aug 14th, 2011, 05:13 AM
#8
Re: PREFIX TO POSTFIX help
Originally Posted by hopia
up... help me.. please..
hopia,
Rather than simply bumping your thread, which serves of no real help, perhaps you might want to think about providing more information to the problem that you are trying to solve. What have you tried? If it didn't work, why not?
Gary
-
Aug 14th, 2011, 06:02 AM
#9
Re: PREFIX TO POSTFIX help
Check out this link:
http://www.chris-j.co.uk/parsing.php
It has a detailed description of the Infix to Postfix notation and later - of the shunting yard algorithm with a step by step example (Java required to view).
-
Aug 14th, 2011, 07:59 AM
#10
Re: PREFIX TO POSTFIX help
Originally Posted by cicatrix
Check out this link:
http://www.chris-j.co.uk/parsing.php
It has a detailed description of the Infix to Postfix notation and later - of the shunting yard algorithm with a step by step example (Java required to view).
I posted that link in the other forum where the OP asked the same question. I don't think the OP has tried.
-
Aug 18th, 2011, 11:57 AM
#11
Thread Starter
Member
Re: PREFIX TO POSTFIX help
I saw the program in the link given above, it is really awesome, I want to to it in visual basic but the problem is I'm having a hard time with an array. I don't know how to use array in a program. hope you can help me please.
-
Aug 18th, 2011, 12:18 PM
#12
Re: PREFIX TO POSTFIX help
Hey,
Here's the C example: http://en.wikipedia.org/wiki/Shuntin...ithm#C_example
Just give it a try to convert it to VB.
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Aug 18th, 2011, 12:23 PM
#13
Re: PREFIX TO POSTFIX help
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Aug 19th, 2011, 09:41 PM
#14
Thread Starter
Member
Re: PREFIX TO POSTFIX help
Originally Posted by akhileshbc
Very nice, Okay I will try it. What is the equivalent of bool, unsigned int, const char in VB??
-
Aug 20th, 2011, 05:21 PM
#15
Re: PREFIX TO POSTFIX help
Originally Posted by hopia
Very nice, Okay I will try it. What is the equivalent of bool, unsigned int, const char in VB??
Boolean, UInteger, Char correspondingly.
-
Aug 20th, 2011, 10:56 PM
#16
Thread Starter
Member
Re: PREFIX TO POSTFIX help
how do i convert this in VB?
bool op_left_assoc(const char c)
also this,
int op_preced(const char c)
-
Aug 20th, 2011, 11:01 PM
#17
Thread Starter
Member
Re: PREFIX TO POSTFIX help
how do i convert this in VB?
#define is_function(c) (c >= 'A' && c <= 'Z')
-
Aug 21st, 2011, 07:33 AM
#18
Re: PREFIX TO POSTFIX help
Just don't try to mindlessly copy and convert the sample code from c++ to vb.net. Even though you can probably end up with something working, it won't probably work as expected.
Instead just understand the algorithm and try to implement it yourself.
1) Tokenize the input string - separate the elements into a number of tokens, for example 1+2/3 will have 5 tokens: 1, +, 2, /, 3.
2) Convert the tokens from infix to postfix, turning 1+2/3 into 1, 2, 3, /, +
3) Implement the Shunting-Yard algorithm to evaluate the postfix queue.
C++ and Vb.Net have enough differences so it would be far better to write your own implementation rather than trying to convert one from C++. From what I see, you don't even try to understand the principle.
Ah, to answer your question
Originally Posted by hopia
how do i convert this in VB?
#define is_function(c) (c >= 'A' && c <= 'Z')
Code:
Private Function is_function(ByVal c As Char) As Boolean
Return c >= "A"c AndAlso c<= "Z"c
End Function
You can click 'Evaluating Expressions' link in my signature and download the Parser class I made for just the same purpose.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|