0
votes

My code finds facts based on value range:

ara_deger_price(L,H,Res) :-
   findall( (Id,B,C,D,Price,F,Points),
            ( table(Id,B,C,D,Price,F,Points),
              \+ Price = null, \+ Price = 'Price', Price > L, Price < H
            ),
            Res).

It gives a list result like so:

?- ara_deger_price(200,250,X).
X = [ (284, 'Viña Cobos 2011 Marchiori Vineyard Block C2 Malbec (Perdriel)', 'Argentina', 'Malbec', 215, 'Michael Schachner', 92), (349, 'Torbreck 2012 RunRig Shiraz-Viognier (Barossa)', 'Australia', 'Shiraz-Viognier', 225, 'Joe Czerwinski', 97)] ;
false.

What I want to do is add every element of this list to a C# listbox. I can access elements using nth0/3 but I want to access every one of them.

I tried this:

show_record([]).
show_record([A|B]) :- write(A), write("\n"), show_record(B).

Which prints every element to one line in the console. Can I redirect the result from console to the listbox or is there a way to access every element in Prolog?

1
Aren't you really asking how to interface a C# program to Prolog? I'm assuming you want to do this programmatically. - lurker

1 Answers

0
votes

I solved the problem and forgot to give an update. Here's the code I used to solve the problem:

aralik_price(L,H,X):-ara_deger_price(L,H,Res), member(X,Res).

It gets the list Res from ara_deger_price and finds every member and returns them all with the X variable. In C#, I can get all the members by simply looping through the X variable.