Discussions related to Visual Prolog
Wabbit
Posts: 3
Joined: 24 Apr 2023 12:25

Set Operations in Visual Prolog

Unread post by Wabbit »

I have:

Code: Select all

helps(Person,Modifier) :- high(Person,Taxon),decreases(Modifier,Taxon). helps(Person,Modifier) :- low(Person,Taxon),increases(Modifier,Taxon). hurts(Person,Modifier) :- low(Person,Taxon),decreases(Modifier,Taxon). hurts(Person,Modifier) :- high(Person,Taxon),increases(Modifier,Taxon).
And I am struggling with a take. Conceptually it should be something like one of those below.

Code: Select all

take(Person,Modifier):- exclude(helps(Person,Modifier),=,hurts(Person,Modifier)). take(Person,Modifier):- remove(helps(Person,Modifier),is,hurts(Person,Modifier)). take(Person,Modifier):- except(helps(Person,Modifier),hurts(Person,Modifier)).
I could push the elements into an array, and then walk them to remove those found. - But I was hoping for a more native solution.

Related: Any plan to add Linq to your implementation? Or even helps(Person,Modifier).ToArray().
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: Set Operations in Visual Prolog

Unread post by Thomas Linder Puls »

I am not sure I understand the question, subsequently anything I answer may be wrong :-).

And I believe your code looks more like ISO Prolog in the sense that you seem to have a vague boundary between code and data.

In Visual Prolog there is no term interpretation machinery, so you cannot pass code around as terms and have it evaluated where you prefer.

Prolog (neither ISO or Visual Prolog) does not have arrays as a "natural" data structure, instead (like functional programming) languages lists is a natural data structure.

Both your Linq and ToArray questions would require that "helps(Person, Modifier)" is some kind of data, but it is a predicate call.
Regards Thomas Linder Puls
PDC
Post Reply