Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
bound variable doesn't work in pattern-matching
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nima  
View profile  
 More options Mar 15 2012, 4:23 am
From: Nima <divoone0...@gmail.com>
Date: Thu, 15 Mar 2012 01:23:46 -0700 (PDT)
Local: Thurs, Mar 15 2012 4:23 am
Subject: bound variable doesn't work in pattern-matching
Hi all,

I have a problem that can not find any reason for it!

in a pattern-matching, when I use a variable that Initialized
manually, pattern-matching work correctly.
But when use a variable that Initialized by binding, pattern-matching
doesn't work.

for example, first code, return 72 and work correctly:

first code:
--------------------------------------------------------------------------
(deffunction Pass-Search (?x)
?x)

(defglobal ?*OS* = Android)

(deffacts Mobile
(Mobile 71 Symbian)
(Mobile 72 Android))

(defrule Result
(Mobile ?name  =(Pass-Search ?*OS*))
=>
(printout t ?name))
--------------------------------------------------------------------------- -

But when ?*OS* gets its value from user by using binding, it doesn't
work correctly:

--------------------------------------------------------------------------- ---
(deffunction Pass-Search (?x)
?x)

(defglobal ?*OS* = Android)

(deffacts Mobile
(Mobile 71 Symbian)
(Mobile 72 Android))

(defrule Questions
(declare (salience 20))
=>
(bind ?response
      (ask-question "2- What Is Your Favorite OS? (A/B/C)" "A.
Android     B. Windows     C. Symbian" a b c))
(if (eq ?response a)
then
(bind ?*OS* Android)))

(defrule Result
(Mobile ?name  =(Pass-Search ?*OS*))
=>
(printout t ?name))

--------------------------------------------------------------------------- -----------------

ask-question is one of my functions.

I hope someone can help me.
Nima


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lode Hoste  
View profile  
 More options Mar 15 2012, 6:12 am
From: Lode Hoste <zill...@gmail.com>
Date: Thu, 15 Mar 2012 11:12:27 +0100
Local: Thurs, Mar 15 2012 6:12 am
Subject: Re: bound variable doesn't work in pattern-matching
Hi Nima,

Try double quoting the "a".

CLIPS> (eq "a" a)
FALSE
CLIPS> (eq "a" "a")
TRUE

2012/3/15 Nima <divoone0...@gmail.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nima  
View profile  
 More options Mar 15 2012, 11:18 am
From: Nima <divoone0...@gmail.com>
Date: Thu, 15 Mar 2012 08:18:35 -0700 (PDT)
Local: Thurs, Mar 15 2012 11:18 am
Subject: Re: bound variable doesn't work in pattern-matching
Hi Lode Hoste,

Unfortunately it didn't  work.
I'm confuse and I do not know what to do!

On Mar 15, 1:12 pm, Lode Hoste <zill...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
CLIPS Support  
View profile  
 More options Mar 15 2012, 12:08 pm
From: CLIPS Support <garydri...@gmail.com>
Date: Thu, 15 Mar 2012 09:08:49 -0700 (PDT)
Local: Thurs, Mar 15 2012 12:08 pm
Subject: Re: bound variable doesn't work in pattern-matching
Read through section 6 of the Basic Programming Guide which describes
how globals work: http://clipsrules.sourceforge.net/OnlineDocs.html

Use facts to pass information from one rule to another:

(defrule Questions
(declare (salience 20))
=>
(bind ?response
      (ask-question "2- What Is Your Favorite OS? (A/B/C)" "A.
Android     B. Windows     C. Symbian" a b c))
(if (eq ?response a)
then
(assert (OS Android))))

(defrule Result
(Mobile ?name  ?OS)
(OS ?OS)
=>
(printout t ?name))

On Mar 15, 3:23 am, Nima <divoone0...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nima  
View profile  
 More options Mar 15 2012, 1:28 pm
From: Nima <divoone0...@gmail.com>
Date: Thu, 15 Mar 2012 10:28:41 -0700 (PDT)
Local: Thurs, Mar 15 2012 1:28 pm
Subject: Re: bound variable doesn't work in pattern-matching
Thanks alot!
It worked corectly very nice.
Thanks you again.

Only one problem remained.
If pattern-matching was true and pattern matched with facts in
knowledge base, I want in out put only  5 facts (for example) be
printout for ?name, not all of them. (Meaning only 5 phones be
recommended to users not all phones are matched)

I used (while), but this way was incorrect.

Nima

On Mar 15, 7:08 pm, CLIPS Support <garydri...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nima  
View profile  
 More options Mar 16 2012, 7:59 am
From: Nima <divoone0...@gmail.com>
Date: Fri, 16 Mar 2012 04:59:16 -0700 (PDT)
Local: Fri, Mar 16 2012 7:59 am
Subject: Re: bound variable doesn't work in pattern-matching
Thanks,
Found the solution.

Thank you again for  the great help.

Best regards,
Nima

On Mar 15, 8:28 pm, Nima <divoone0...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »