c# - 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. 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?
解决方案
我解决了这个问题,忘了提供更新。这是我用来解决问题的代码:
aralik_price(L,H,X):-ara_deger_price(L,H,Res), member(X,Res).
Res
它从中获取列表ara_deger_price
并找到每个成员并使用 X 变量将它们全部返回。在 C# 中,我可以通过简单地遍历 X 变量来获取所有成员。
推荐阅读
- c# - 如何在 TextChange 事件中更改 MaskedTextBox 的文本颜色?
- android - 无法连接到流星 android-device 上的托管或本地 mongo
- javascript - 为什么我的函数会过滤掉零和字符串?
- git - 用于通用远程存储库的 MacOS SourceTree 清除凭证助手
- python - 类变量不与类实例共享
- python - 寻求有关python项目的帮助
- python - Pythong PuLP 约束:如何构建递归约束
- php - 网站上 CSS 搜索结果的问题
- python - 使用 Python Selenium 登录到具有 JS 生成的登录表单的网站
- java - 如何下载excel并在单击jsp上的链接时从spring控制器返回一些错误消息