Print Page | Close Window

Reverse Polish Notation Question

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1745
Printed Date: 13-Sep-2025 at 7:44pm


Topic: Reverse Polish Notation Question
Posted By: evanian
Subject: Reverse Polish Notation Question
Date 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!



Replies:
Posted By: GregD
Date 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.




Posted By: smi-mark
Date 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!!!


Posted By: evanian
Date 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 :)


Posted By: GregD
Date 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-)



Print Page | Close Window