wow thats a lot ppl ...i now realize how stupid my question was but you guys gave me great answers and a ton of help on my project.
im gonna try it both ways with from jason and alan thnx a ton guys ...and ill think a little bit before my next post! -Jerome BG --- Jason Morris <[EMAIL PROTECTED]> wrote: > On 9/28/05, Alan Moore > <[EMAIL PROTECTED]> wrote: > > Jerome, > > I'm a little confused as to why your example below > would work for either > > set of facts. > > Hey Jerome, > > Perhaps this generic example will be of some > help.... > > Since you introduced the notion of sets, let's say > that we have a set > called A. For sake of argument, we'll add that set > A has five > properties. We'll call this set of properties X and > we can write > that: > > X = {x1, x2, x3, x4, x5} > > So, each element of A can be defined by the values > of its five > properties. If we represent elements of set A by > ordered facts of > type A, then we can write: > > (deftemplate A > (slot x1) (slot x2) (slot x3) (slot x4) (slot x5)) > > Now, let's say that we want to find a subset, B, of > all type A facts > having certain property values. Note that we're not > creating any new > facts of type B. We are just extracting a subset > from the collection > of A facts. To do this, we simply restrict the slot > values using > Jess's constraints. > > For example, if you asked me to find subset B such > that: > > x1 < 3 > x2 > 2 > x3 = x4 > x5 = nil > > I could write: > > (defrule find-subset-B > (A (x1 ?x1&:(< x1 3)) (x2 ?x2&:(> x2 2)) (x3 ?x3) > (x4 ?x3) (x5 nil)) > => > ; Rule actions go here... > ) > > This rule would fire on all facts of type A for > which these > constraints were satisfied. > A complete program is given below. > > Cheers, > -Jason > ----------------------------------------------------- > Morris Technical Solutions LLC > www.morristechnicalsolutions.com > [EMAIL PROTECTED] > phone/fax: 503.692.1088 > > > ;; ------------------------- > ;; subset.clp > ;; ------------------------- > > ; INIT > (clear) > (watch rules) > > (deftemplate A > (slot x1) (slot x2) (slot x3) (slot x4) (slot > x5)) > > ; Load some data > (deffacts load-all-A-facts > (A (x1 3) (x2 9) (x3 8) (x4 2) (x5 0.4)) > (A (x1 -2) (x2 5) (x3 0.3) (x4 0.3) (x5 nil)) > (A (x1 1) (x2 3) (x3 7) (x4 5) (x5 8)) > (A (x1 3) (x2 5) (x3 9) (x4 1) (x5 nil)) > (A (x1 9) (x2 3) (x3 8) (x4 4) (x5 5)) > (A (x1 3) (x2 2) (x3 1) (x4 1) (x5 2)) > (A (x1 1) (x2 5) (x3 4) (x4 4) (x5 nil)) > (A (x1 0) (x2 4) (x3 4) (x4 1) (x5 3))) > > ; Filter set A for subset B > (defrule find-subset-B > ?fact<- (A (x1 ?x1&:(< ?x1 3)) (x2 ?x2&:(> ?x2 > 2)) (x3 ?x3) (x4 > ?x3) (x5 nil)) > => > (printout t (fact-id ?fact) " matches!" crlf)) > > ; PROGRAM > (reset) > (run) > > ; OUTPUT > ;Jess, the Rule Engine for the Java Platform > ;Copyright (C) 2005 Sandia Corporation > ;Jess Version 7.0b2 8/11/2005 > ; > ;FIRE 1 MAIN::find-subset-B f-7 > ;<Fact-7> matches! > ;FIRE 2 MAIN::find-subset-B f-2 > ;<Fact-2> matches! > > > -------------------------------------------------------------------- > To unsubscribe, send the words 'unsubscribe > jess-users [EMAIL PROTECTED]' > in the BODY of a message to [EMAIL PROTECTED], > NOT to the list > (use your own address!) List problems? Notify > [EMAIL PROTECTED] > -------------------------------------------------------------------- > > __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------