Hello Jason,

that's also exactly what I tried to realize. I thought it could be shorter ;-)

Thank you 
Sven

Am Mittwoch, 25. August 2004 00:48 schrieb Jason Morris:
> I think that Sven wrote:
> >> How can i modify my rule so that it really picks out the right encoding?
>
> Hi Sven,
>
> Bob may have already given you what you need, but here's another thought.
> Try this batch file and see if it's the behavior that you want.
> Note that I changed your templates a bit.
>
> ;;==== best.clp ====
> (clear)
> ;;(watch all) ;;you can toggle this on/off
>
> ;; Devices have multiple encodings, which have their own details.
> (deftemplate device
>   (slot id)
>   (multislot encoding-ids)) ;; a list of encoding "id"s.
>
> ;; Acts like a "linking table" in a RDBMS
> (deftemplate encoding
>   (slot id)
>   (slot type)
>   (slot rank))
>
> ;; Returns the minimum value of a numeric list.
> (deffunction min-value (?list)
>   (bind ?min (nth$ 1 (first$ ?list)))
>   (foreach ?n (rest$ ?list)
>     (if (numberp ?n) then
>       (if (< ?n ?min) then
>         (bind ?min ?n))
>      else
>       (printout t "Non-numeric list" crlf)
>       (return nil)))
>   (return ?min))
>
> ;; Load a test factbase
> (deffacts devices-and-encodings
>   (device (id 1) (encoding-ids 1 3 4))
>   (device (id 2) (encoding-ids 1 3 4))
>   (device (id 3) (encoding-ids 2 5))
>   (device (id 4) (encoding-ids 1 3 5))
>   (device (id 5) (encoding-ids 2 4))
>   (encoding (id 1) (type MP3) (rank 1))
>   (encoding (id 2) (type RM) (rank 2))
>   (encoding (id 3) (type AVI) (rank 3))
>   (encoding (id 4) (type WAV) (rank 4))
>   (encoding (id 5) (type AU) (rank 5))
> )
> ;; This fires for each device in inventory, printing its best quality
> encoding.
> (defrule find-best-encoding-for-each-device
> "For each device, print its best (lowest) encoding rank."
>   (device (id ?dev-id) (encoding-ids $?enc-ids))
>   (encoding (id ?id) (type ?t) (rank =(min-value $?enc-ids)))
> =>
> ;; Get the best encoding for this device
> (printout t "The best quality encoding for device id " ?dev-id " is " ?t
> crlf))
>
> (reset)
> (run)
> ;;==============================================
>
> Jess prints out...
> Jess> (batch best.clp)
> The best quality encoding for device id 5 is RM
> The best quality encoding for device id 3 is RM
> The best quality encoding for device id 4 is MP3
> The best quality encoding for device id 2 is MP3
> The best quality encoding for device id 1 is MP3
> 5
> Jess>
>
>
> Hope this helps!
> Cheers,
>
> Jason
> ------------------------
>
> Jason Morris
> Morris Technical Solutions
> [EMAIL PROTECTED]
> www.morristechnicalsolutions.com
> fax/phone: 503.692.1088
>
>
>
>
> --------------------------------------------------------------------
> 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]
> --------------------------------------------------------------------


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