On Tue, 17 Aug 1999, Burke,Carl D. wrote:

I would write this as:

(assert (color (create$ blue red green )))
(assert (color (create$ red green blue )))

(defrule colorsee
  ?r <- (color ? green $?colors)
  =>
  (printout t "In fact " ?r " second colour is green" crlf))

Hope it helps

Vadim


> [sent to individual and list]
> 
> You need to do a test on the second element of $?colors,
> rather than trying to match a pattern with it.  (You may
> be able to do this with pattern matching, but I'm not
> quite sure how yet.)
> 
> This code seems to give the expected result:
> <<
> (assert (color (create$ red green blue)))
> 
> (defrule colorsee
>    (color $?colors&:(eq (nth$ 2 $?colors) green))
> =>
>   (printout t "colors 2: " (bind ?element (nth$ 2 $?colors)) crlf)
>   (printout t " list :"  $?colors crlf))
> >>
> 
> You could probably put the (eq ) in a separate (test ) CE
> and get the same result.  This test doesn't seem robust,
> because it assumes that you have at least two elements in
> your color list; if your rulebase is going to meet that
> condition, this rule should work OK.
> 
> Hope this helps.
> 
> At 06:58 PM 8/17/99 -0300, you wrote:
> >Thanks for your help, but it didn't  work.
> ....
> >Venkatachalam Kanthim wrote:
> >
> >> hi:
> >>
> >> I recall having this problem before.
> >>
> >> Try (nth$ 2 $?colors) instead of (nth $2 $?colors). Guess this a
> >> slight difference in notation from CLIPS.
> >>
> >> Hope it works.
> >>
> >> ---
> >> Venkat
> >>
> >> In message <[EMAIL PROTECTED]>you write:
> >>  >
> >>  >Hello List
> >>  >
> >>  >I'm sorry for the primary questions, but given the following list. As to
> >>  >verify the color of the 2nd element of the list.
> >>  >(assert (color (create $red green blue)))
> >>  >
> >>  >(defrule colorsee
> >>  >   (color $?colors)
> >>  >   ((bind ?element (nth $2 $?colors)) green)              ---> it gives
> >>  >mistake...
> >>  >  =>
> >>  >  (printout t "colors 2: " (bind ?element (nth $2 $?colors)) crlf)
> >>  >  (printout t " list :"  $?colors crlf))
> 
> --
> Carl Burke
> [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
> 

-- 
;;-----------------------------------+-----------------------------------+
;; [EMAIL PROTECTED]      + Those who do not understand Unix  +
;; Project Manager, Matranet Inc.    + are condemned to reinvent it,     +
;; http://www.matranet.com/          + poorly.          (H. Spencer)     +
;;-----------------------------------+-----------------------------------+

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

Reply via email to