[英]Adding prolog list elements to listbox items in c#
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. 我想做的就是将此列表的每个元素添加到C#列表框中。 I can access elements using nth0/3 but I want to access every one of them.
我可以使用nth0 / 3访问元素,但是我想访问其中的每个元素。
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?
我可以将结果从控制台重定向到列表框,还是可以访问Prolog中的每个元素?
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. 它从
ara_deger_price
获取列表Res
,并找到每个成员,并使用X变量将其全部返回。 In C#, I can get all the members by simply looping through the X variable. 在C#中,我可以通过简单地遍历X变量来获取所有成员。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.