新手求问prolog list
prolog吧
全部回复
仅看楼主
level 1
lenliusy
楼主
各位大神、本人接触prolog不久,最近有道题,如何用列表list 和mod ,列出输入的数字里面的所有偶数?就像
?-even_list(【1,2,3,4】,L)
L=(【2,4】)
2016年04月25日 04点04分
1
level 13
丁兔
even_list([],[]).
even_list(L,Le):-
L=[H|T],
0 is H mod 2,
even_list(T,Te),
Le=[H|Te].
even_list(L,Le):-
L=[H|T],
\+ 0 is H mod 2,
even_list(T,Te),
Le=Te.
2017年05月26日 04点05分
2
1