I have code with a construct that appears repeatedly with only a small difference consisting of a different predicate call each time. I want to create a predicate that can take a predicate as an argument.
Here is the generic predicate:
array_def (_,[],[]) :- !. array_def(Type,[H|T],[H0|T0]) :- !,Type(H,H0), array_def(T,T0). array_def(Type,H,[H0]) :- Type(H,H0).
Type is a variable predicate where H is an input and H0 is an output. An example is:
value_literal(H,H0) :- number_literal(H,H0), !. value_literal(H,H0) :- string_literal(H,H0), !. value_literal(H,H0) :- boolean_literal(H,H0).
So I want to declare something like this:
value_literal_array(Arr,Arr0) :- array_def(value_literal(...,...),Arr,Arr0), ...
I don't understand the description of call/2 in the manual. Is there a way to use that? If so, how? If not, how else can I do this? How would I include it in array_def and how would I
Thanks, John