首页 > 解决方案 > 运行此序言代码时显示错误

问题描述

运行此序言代码以查找数字列表的因子时显示语法错误

factors( N , Fs ) :-
  integer(N) ,
  N > 0 ,  
  setof( F , ( between(1,N,F) , N mod F =:= 0 ) , Fs )
  .
fact(List ,Result) :- 
    display( maplist(factors,[10 12 16],Result))
  . 

标签: listsyntaxprologintegerfactors

解决方案


这不是 Prolog 中的列表:

[10 12 16]

正确的写法是这样的:

[10, 12, 16]

您需要列表元素之间的逗号。


推荐阅读