New Posts New Posts RSS Feed: Reverse Polish Notation Question
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Reverse Polish Notation Question

 Post Reply Post Reply
Author
evanian View Drop Down
Newbie
Newbie


Joined: 23-Apr-2010
Posts: 7
Post Options Post Options   Quote evanian Quote  Post ReplyReply Direct Link To This Post Topic: Reverse Polish Notation Question
    Posted: 23-Apr-2010 at 9:23am
I am just getting into OQL and I need to build a query of the following algebraic form:

Condition1 AND ((Condition2 AND Condition3) OR (Condition4 AND Condition5)) AND Condition6

Is there a way of doing this?

Any help would be greatly appreciated!
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 23-Apr-2010 at 5:56pm
That's a bit of a nasty one, but I think with a little study of the table below (from the Object Persistence chapter of the Developers Guide) you will see how to write your query.  You have, algebraically,

    A and ((B and C) or (D and E)) and F

So I believe that translates to

   A BC and DE and or and F and

The operator always applies to the two most recently listed operands.

Algebraic Notation v. Reverse-Polish

The following table compares algebraic notation to the corresponding Reverse-Polish notation.  If you’re accustomed to thinking algebraically, as many of us are, just find the relationships you need in the left-hand column and see the Reverse-Polish equivalent in the right-hand column.  Not every possible construction is covered, but with a few minutes of meditation – as especially, with comparison to the examples given above -- you’ll get the idea.




Edited by GregD - 23-Apr-2010 at 6:00pm
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 23-Apr-2010 at 6:43pm
That's a great chart, Greg. I still have several projects in DevForce Classic, and it really makes you appreciate LINQ queries in EF!!!
Back to Top
evanian View Drop Down
Newbie
Newbie


Joined: 23-Apr-2010
Posts: 7
Post Options Post Options   Quote evanian Quote  Post ReplyReply Direct Link To This Post Posted: 26-Apr-2010 at 1:22am
Thanks, that's just what I needed.  I didn't realise that the rule was "the operator always applies to the two most recently listed operands".  It finally makes full sense of the table :)
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 26-Apr-2010 at 11:42am
Originally posted by smi-mark

That's a great chart, Greg. I still have several projects in DevForce Classic, and it really makes you appreciate LINQ queries in EF!!!


Reverse Polish does have a sort of Vulcan beauty to it; but yeah, I'd have to go with LINQ.  8-)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down