[mercury-users] Specific If Clause Goal/Expression problem

Goncalo Jorge Coelho e Silva l10454 at alunos.uevora.pt
Fri May 16 11:52:49 AEST 2003

Hi again,

 I was working on code to check if a given string
contains a '/' character, and if so, produce a 
list of strings separated by the '/' char itself.
(Sort of a string__words predicate with a is_slash
predicate as it's 1st arg, instead of char__is_whitespace)
... but as a function.

 So far, so good but when I try to use the resulting
list to compare it with [], i get:

inter.m:094: In clause for predicate `inter:chooseInstruct/5':
inter.m:094:   error: the language construct =/2 should be
inter.m:094:   used as a goal, not as an expression.
inter.m:094:   If you are trying to use a goal as a boolean function,
inter.m:094:   you should write `if <goal> then yes else no' instead.
make: *** [run] Error 1

chooseInstruct(ChoppedString, ChoppedString2, ChoppedCommaList)-->
         if {(checkLabel(ChoppedString)= ChoppedCommaList) \= []} then
		% (!) Technically, I shouldn't have used the name
		%   'ChoppedCommaList' on this result but
		%   'ChoppedSlashList' or something...
                io__write_string(" Label! ")
                % pprint(ChoppedCommaList)
                % doSomethingWith Label
                % doSomethingWith ChoppedString2
        if {ChoppedString = "put_structure"} then

checkLabel(ChoppedString)= ChoppedSlashList :-
       string__words(is_slash, ChoppedString) = ChoppedSlashList.

        string__to_char_list("/") = [H|T],
        H = Char.

 Can't I use the following expression, or something similar
to this with the same effect in an if clause ? :

(checkLabel(ChoppedString)= ChoppedCommaList)\= []

% Compares the List resulting from applying the
% function to a string, against a empty list


mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe

More information about the users mailing list