Hi!

Look at the following two functions that I happened to write today:

(deffunction str-contains (?whole ?part)
     (integerp (str-index ?part ?whole)))

(deffunction str-contains-ignore-case (?whole ?part)
     (str-contains (lowcase ?whole) (lowcase ?part)))

str-contains checks to see if ?whole contains a substring ?part. The
integerp predicate function is needed becaus str-index either returns an
Integer (i.e., ?part's position in case ?whole contains ?part) or FALSE (in
case ?whole does not contain ?part).

You would use these functions as follows:

(defrule your-rule
     (row (name ?name&:(str-contains ?name "new")) (value ?b))
     =>
     (printout t "List: " ?b crlf))

Greetings

Thomas


________________________________

Dipl.-Inform. Thomas Barnekow
Fraunhofer IAO, Competence Center Software Technology
                                               
 mail:   Nobelstra�e 12, D-70569 Stuttgart,    
         Germany                               
                                               
 phone:  +49 (0) 711 / 970 - 2346              
                                               
 fax:    +49 (0) 711 / 970 - 2300              
                                               
 mobile: +49 (0) 172 / 7126018                 
                                               
 email:  [EMAIL PROTECTED]            
                                               
 web:    http://www.swt.iao.fhg.de             
                                               





                                                                                       
                    
                    "Skokan,                                                           
                    
                    Ladislav"                To:     Jess Mailing List 
<[EMAIL PROTECTED]>             
                    <ladislav.skokan@        cc:                                       
                    
                    eds.com>                 Subject:     JESS: Something like 
patterns in Jess            
                    Sent by:                                                           
                    
                    owner-jess-users@                                                  
                    
                    sandia.gov                                                         
                    
                                                                                       
                    
                                                                                       
                    
                    28.03.00 14:17                                                     
                    
                    Please respond to                                                  
                    
                    "Skokan,                                                           
                    
                    Ladislav"                                                          
                    
                                                                                       
                    
                                                                                       
                    




Hello All

I am new in Jess/Lisp and I am faced to solve such problem:
This  is simplified example:

>>>>>>>>>>> code
(deftemplate row (slot name) (slot value))

(assert (row (name new) (value 1)) )
(assert (row (name news) (value 1)) )

(defrule list (row (name new) (value ?b)) => (printout t "List:"  ?b crlf
))
(run)
>>>>>>>>>>>>>> code

I now need to list each row , where name STARTS with or CONTAINS  the word
"new".
This example lists only words exactly maching name "new".

Does anybody have any idea how to do it ?

Thanx,
Laco Skokan.

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