infinite loop caused by append SWi prolog -


i trying code adds value list empty. program keeps going infinite loop or out of stack, when using append.

i using swi prolog , new prolog.

getcardvaluelist([],[_]). getcardvaluelist([h|ts],[_]):-    getcardvalue(h,val),    append([_],[val],vl),    getcardvaluelist(ts,vl).  append([x|y],z,[x|w]) :- append(y,z,w). append([],x,x).  

you're using lists in strange way, i'm unsure purpose of code.

anyway, think you're attempting code maplist, do

getcardvaluelist(cards, values) :-    maplist(getcardvalue, cards, values). 

if attempting this, can show 'amended' code:

getcardvaluelist([],[]). getcardvaluelist([card|cards],[val|vals]):-   getcardvalue(card,val),   getcardvaluelist(cards,vals). 

no need append, list constructions done means of patterns in head'arguments. note should avoid redefine library predicates, append/3.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -