Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fact matching more than once for a rule #55

Closed
devijvers opened this issue Aug 22, 2013 · 3 comments
Closed

Fact matching more than once for a rule #55

devijvers opened this issue Aug 22, 2013 · 3 comments

Comments

@devijvers
Copy link

define Thing {
  constructor: function(value) {
    this.value = value;
  }
}

rule "some rule" {
   when {
     $1: Thing $1.value == "something";
     $2: Thing;
   }
}

The fact matched by $1 will also be matched by $2, that doesn't feel right in my opinion. Matching typically happens left-to-right, therefore $1 should have priority over $2.

@devijvers
Copy link
Author

I've checked Prolog, apparently this is perfectly normal behavior. In Prolog you would have to add $1 = $2 to enforce that both can't be equal. Is this possible with nools constraints?

@doug-martin
Copy link
Contributor

Yes if they are the same exact object then you could do the following

define Thing {
  constructor: function(value) {
    this.value = value;
  }
}

rule "some rule" {
   when {
     $1: Thing $1.value == 'something';
     $2: Thing $2 != $1;
   }
}

@devijvers
Copy link
Author

$2: Thing $2 != $1;

Thanks, I've confirmed this to be correct. I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants