我需要打印列表元素,但我遇到麻烦...... 我有这样的事实:
Error:(46, 51) could not find implicit value for parameter threshold: com.amazon.zen.datavalidation.activity.com.amazon.zen.datavalidation.activity.ThresholdMethods[org.apache.spark.sql.types.DataType]
ThresholdMethodsInstances.thresholdMatcher(df1.schema("T1").dataType)
Error:(46, 51) not enough arguments for method thresholdMatcher: (implicit threshold: com.amazon.zen.datavalidation.activity.com.amazon.zen.datavalidation.activity.ThresholdMethods[org.apache.spark.sql.types.DataType])Boolean.
Unspecified value parameter threshold.
ThresholdMethodsInstances.thresholdMatcher(df1.schema("T1").dataType)
我通过findall函数过滤这些配置:
processor('Intel Core i3 8100', 104, 'low_range') .
processor('Ryzen 5 2400g', 135, 'middle_range').
motherboard('Gigabyte Z370P D3', 98, 'low_range') .
motherboard('Gigabyte GBT AX370M-DS3H', 70, 'middle_range').
.....
configuration(P, M, R, C, A, V, S, D, H, Price_range) :-
processor(P, _Proc_price, Price_range),
motherboard(M, _Motherboard_price, Price_range),
ram(R, _Ram_price, Price_range),
case(C, _Case_price, Price_range),
ali(A, _Ali_price, Price_range),
video_card(V, _Vga_price, Price_range),
ssd(S, _Ssd_price, Price_range),
monitor(D, _Monitor_price, Price_range),
hdd(H, _Hdd_price, Price_range).
我需要以这种方式打印Res元素:
findall(P-M-R-C-A-V-S-D-H, configuration(P, M, R, C, A, V, S, D, H, T), Res),
你能帮帮我吗?我不明白该怎么做
答案 0 :(得分:1)
您可能希望使用forall/2
代替findall/3
:
forall(:Cond, :Action)
对于 Cond 的所有替代绑定,可以证明 Action 。
e.g:
forall(configuration(P, M, R, C, A, V, S, D, H, T),
(writeln(configuration), writeln(P), writeln(M), ...)).
编辑:你可以用这种方式制作一个计数器:
:- dynamic(mycounter/1).
:- assertz(mycounter(0)).
incr_mycounter(X):-
mycounter(X),
retractall(mycounter(_)),
succ(X,Y),
assertz(mycounter(Y)).
并像这样使用它:
forall(configuration(P, M, R, C, A, V, S, D, H, T),
(incr_mycounter(N), writeln(configuration-N), writeln(P), writeln(M), ...)).