Re: [eclipse-clp-users] Not equal constraint in String

From: Joachim Schimpf <jschimpf_at_coninfer.com>
Date: Mon, 22 Jun 2015 08:30:11 +0100
On 22/06/15 06:16, mskala_at_ansuz.sooke.bc.ca wrote:
> On Mon, 22 Jun 2015, Edgaonkar, Shrirang wrote:
>> What is the difference ? Am I missing anything here ?
>
> \= isn't a constraint and it doesn't mean "not equal."  It is a logical
> statement true if its operands cannot be unified.
>
> In your second example, when the interpreter attempts to satisfy
> STR1 \= "", at that point STR1 is a free variable.  It *can* in fact be
> unified with "", so the statement "it is not possible to unify STR1 with
> "" " is false, and the goal fails.  The other example worked because it
> was waiting until STR1 had a (ground, not free variable) value before
> testing it.
>
> I don't know if the not-equal constraints in any of the constraint
> libraries will work with strings, but that's what you need; if there isn't
> one ready-made, you may have to create a custom one.
>

You can use ~=, which is a generic not-equals constraint, see
http://eclipseclp.org/doc/bips/kernel/termcomp/TE-2.html


-- Joachim
Received on Mon Jun 22 2015 - 07:57:01 CEST

This archive was generated by hypermail 2.2.0 : Tue Jun 23 2015 - 03:14:13 CEST