I need to write a program that constructs a minimal dominating vector for a set of N-Dimensional vectors. A dominating vector for a set S of vectors is defined as a vector whose ith component is greater than or equal to the ith component of every vector in S, with i ranging over all dimensions of the vectors. The dimension N must be taken as input from the user.
Share
Prolog doesn’t have vectors. You can use lists, or structs of arity N.
In second case of course N must be less than the max arity allowed (SWI-Prolog has unlimited length…)
If you use lists, this code should do. I assume N is implicit from list length.
test:
If your Prolog doesn’t have maplist/4 (I can’t remember this detail of P#) then replace
maplist(min, V, MinSoFar, Updated),withminvect(V, MinSoFar, Updated),, and add this definitionnote, OT when I tried P# some year ago, I found it very slow, and memory ungry. If you have big arrays, then you’re better to use LINQ