Are there any modules that deal with building a prefix notation boolean logic tree? Maintaining the order is important. A LoL is preferred. I have a feeling that this is something that someone has already done somewhere. I have some thoughts on how to start on this but there may be cases I'm missing. The goal is not to represent any type of tree but one that a user would enter rule by rule. i.e.
user enters the first clause. User ands a new clause to the end. User or's a new clause to the end of that. User and's a new clause to the end of that. Should build a tree using standard precedence rules.
I don't know if I'm explaining myself that well, it's late and I've been staring at other parts of this for too long. :) Anyway, here's an example of the type of list I'd like to create. I searched cpan for prefix notation logic trees, googled for the same. No real success. Anyone ever done something like this or have pointers to an algorithim to help construct this thing? I have some thoughts on how to start it but I figure the more input I get the less chance of making a mistake. 'sides some of you guys are hella smart. :)
# user adds first clause
[==,a,b] # implies if a == b, prefix notation
# and a new clause
[and,[==,a,b],[==,c,d]]
# or a new clause
[or,[and,[==,a,b],[==,c,d]],[==,e,f]]
# and a new clause
[or,[and,[==,a,b],[==,c,d]],[and,[==,e,f],[==,g,h]]
etc
This would be the representation of the above in infix notation
((a==b)and(c==d))or((e==f)and(g==h))
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.