A simple prolog syntax question -
in user mode in swi-prolog define function follows:
|: test1(+x,+y) :- x >= 0, x =:= y.
and in query mode:
?- test1(1, 1). false.
i expecting return "true" since 1 greater 0 , 1 equal 1.
so did go wrong?
this want instead:
test1(x,y) :- x >= 0, x =:= y.
and then:
?- test1(1, 1). true.
adding +, - , ? in front of predicate arguments not part of prolog. convention documenting how predicates should used.
here gnu-prolog documentation has say:
the mode specifies whether or not argument must instantiated when built-in predicate called. mode encoded symbol before type. possible modes are:
- +: argument must instantiated.
- -: argument must variable (will instantiated if built-in predicate succeeds).
- ?: argument can instantiated or variable.
in actual code, should not prefix arguments +.
Comments
Post a Comment