1
다른 문제가 있습니다 : 일부 단어가있는 목록이 있습니다. 단어의 길이가 주어진 길이 (예 : 4)보다 길면 다른 목록에 넣습니다.Sicstus Prolog - 목록에 단어 넣기
내가 시도 :
require_min_length([], _, []).
require_min_length([Word|Words], Minl, [List]):-
word_length(Word, W), % method word_length return the length of a word.
(W >= Minl -> append(Word, List, List), require_min_length(Words, Minl, List);
require_min_length(Words, Minl, List)).
결과는 내가 가지고 :
| ?- Words=["ABCD", "ABCDE", "AAA"], require_min_weight(Words, 5, Lists).
! Resource error: insufficient memory.
권리 결과는 다음과 같습니다
Lists = [[65, 66, 67, 68, 69]]. (% ascii)
어떻게 코드를 변경? 어떤 도움 pls! 감사.