Results 1 to 18 of 18

Thread: PREFIX TO POSTFIX help

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    52

    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.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,289

    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 -

  3. #3
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,764

    Re: PREFIX TO POSTFIX help

    As in:

    Prefix

    and

    Postfix

    What about

    Infix?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  4. #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.

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    52

    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..

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,764

    Re: PREFIX TO POSTFIX help

    Quote Originally Posted by formlesstree4 View Post
    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/
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    52

    Re: PREFIX TO POSTFIX help

    up... help me.. please..

  8. #8
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: PREFIX TO POSTFIX help

    Quote Originally Posted by hopia View Post
    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

  9. #9
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    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).

  10. #10
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,764

    Re: PREFIX TO POSTFIX help

    Quote Originally Posted by cicatrix View Post
    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.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  11. #11

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    52

    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.

  12. #12
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    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,...

  13. #13
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    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,...

  14. #14

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    52

    Re: PREFIX TO POSTFIX help

    Quote Originally Posted by akhileshbc View Post
    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.
    Very nice, Okay I will try it. What is the equivalent of bool, unsigned int, const char in VB??

  15. #15
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: PREFIX TO POSTFIX help

    Quote Originally Posted by hopia View Post
    Very nice, Okay I will try it. What is the equivalent of bool, unsigned int, const char in VB??
    Boolean, UInteger, Char correspondingly.

  16. #16

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    52

    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)

  17. #17

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    52

    Re: PREFIX TO POSTFIX help

    how do i convert this in VB?
    #define is_function(c) (c >= 'A' && c <= 'Z')

  18. #18
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    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

    Quote Originally Posted by hopia View Post
    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
  •  



Click Here to Expand Forum to Full Width