Using "anyflow" works in "pro" file but seems to need all declared iterations in the "cl" file.
Posted: 18 Oct 2019 2:10
This is only my 2nd post and again I'll state again I haven't developed with prolog in about 30 years until just recently (my previous experience being "Turbo Prolog" in the late 80's).
So I have this quick question. I created a predicate called "slide" that (slides) through a List performing some basic pattern matching (I know someone will say there is already a predicate for that, but its also a learning exercise--although I would like to know the predicate name!). Here is one of the declarations:
I can declare that as a "class predicate" in the ".pro" file, and it works fine. However, if I try to "expose" it by declaring in the ".cli", I get the error: "error c243 : Illegal flow pattern 'anyflow'."
Hopefully it is clear I want V1, V2, V3 to be either "in" or "out" parameters so I can make calls like this (not a very good example but hopefully you get the idea):
However, if I add all the possible iterations of the predicate in/out in the ".cl" file, it will compile! As in:
If I want to add a (slide5) the iterations obviously keep increasing. What is the best way to handle a situation like this in Visual Prolog?
Thanks in advance!
P.S. For context, here the source for a simpler version (slide3) if it will help.
So I have this quick question. I created a predicate called "slide" that (slides) through a List performing some basic pattern matching (I know someone will say there is already a predicate for that, but its also a learning exercise--although I would like to know the predicate name!). Here is one of the declarations:
Code: Select all
slide : (Elem* Source, Elem V1, Elem V2, Elem V3) nondeterm anyflow.
Hopefully it is clear I want V1, V2, V3 to be either "in" or "out" parameters so I can make calls like this (not a very good example but hopefully you get the idea):
Code: Select all
L = [ V || slide(["I", "am", "who", "I", "said", "I", "am"], V, "I", _V2) ]
-or-
L = [ Keyword1 || slide(["I", "am", "who", "I", "said", "I", "am"], "I", Keyword1, _Keyword2) ]
Code: Select all
predicates
% o o o
% o o i
% o i i
% i o o
% i i o
% i i i
% o i o
% i o i
slide4 : (Elem* Source, Elem V1 [out], Elem V2 [out], Elem V3 [out]) nondeterm.
slide4 : (Elem* Source, Elem V1 [out], Elem V2 [out], Elem V3) nondeterm.
slide4 : (Elem* Source, Elem V1 [out], Elem V2, Elem V3) nondeterm.
slide4 : (Elem* Source, Elem V1, Elem V2 [out], Elem V3 [out]) nondeterm.
slide4 : (Elem* Source, Elem V1, Elem V2, Elem V3 [out]) nondeterm.
slide4 : (Elem* Source, Elem V1, Elem V2, Elem V3) nondeterm.
slide4 : (Elem* Source, Elem V1 [out], Elem V2, Elem V3 [out]) nondeterm.
slide4 : (Elem* Source, Elem V1, Elem V2 [out], Elem V3) nondeterm.
Thanks in advance!
P.S. For context, here the source for a simpler version (slide3) if it will help.
Code: Select all
% TEST FOR END OF LIST
slide([_H], _V1, _V2) :-
fail.
% TEST FOR THE SUCCESS CASE
slide([H, TH | _TT], V1, V2) :-
V1 = H,
V2 = TH,
succeed.
% RECURSE
slide([_H | T], V1, V2) :-
slide(T, V1, V2).