I think Eunice Palmeira wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello,
>    I have Unordered facts defined for the template:
> 
> (deftemplate employee
>     (slot name (type STRING))
>     (slot age (type INTEGER))
>     (slot salary (type LONG)))
> 
>    I intend to list the employees ordered for salary.
>  How do i get using rules?
>    Thanks, Eunice Palmeira

A rule like

(defrule top-employee
  ?e <- (employee (name ?name) (salary ?s))
  (not (employee (salary ?s2&:(? ?s2 ?s))))
  ...

Matches the highest paid employee. You can process this one fact, then
remove it, or modify it so it no longer matches, or assert a flag of
some kind; and then the rule fires again for the next highest.

Alternatively, you use a defquery to get all the employees, then sort
the list in Java code.

---------------------------------------------------------
Ernest Friedman-Hill  
Advanced Software Research          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

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