:-module(_,[sift/2],[]). '$applied_packages'([prelude,nonpure,condcomp,assertions,regtypes,nativeprops,rtchecks_shallow,predefres(res_steps),resdefs,resdefs/resources_decl,basicmodes,argnames,expander]). :-add_clause_trans(expander_tr:expand_clause/4,9910). :-prop intlist/1+regtype. :-entry sift(_A,_B):(intlist(_A),var(_B)). :-check calls sift(Is,Ps):(intlist(Is),var(Ps)). :-true success sift(Is,Ps):(intlist(Is),var(Ps))=>intlist(Ps). :-true pred sift(Is,Ps):(intlist(Is),term(Ps))=>(list(Is,character_code),list(Ps,character_code)). :-true pred sift(Is,Ps):(mshare([[Ps]]),var(Ps),ground([Is]))=>ground([Is,Ps]). :-checked calls sift_i(Is,Ps):(intlist(Is),var(Ps)). :-checked success sift_i(Is,Ps):(intlist(Is),var(Ps))=>intlist(Ps). :-true pred sift_i(Is,Ps):(intlist(Is),term(Ps))=>(list(Is,character_code),list(Ps,character_code)). :-true pred sift_i(Is,Ps):(mshare([[Ps]]),var(Ps),ground([Is]))=>ground([Is,Ps]). :-checked calls remove(Is,P,Ps):(intlist(Is),int(P),var(Ps)). :-checked success remove(Is,P,Ps):(intlist(Is),int(P),var(Ps))=>intlist(Ps). :-true pred remove(Is,P,Ps):(intlist(Is),int(P),term(Ps))=>(list(Is,character_code),int(P),list(Ps,character_code)). :-true pred remove(Is,P,Ps):(mshare([[Ps]]),var(Ps),ground([Is,P]))=>ground([Is,P,Ps]). :-prop intlist(_A)+regtype. sift(_1,_2) :- 'sift$pre'(_1,_2), 'sift$cls'(_1,_2). 'sift$pre'(_1,_2) :- reify_check(intlist(_1),[_1],_3), reify_check(var(_2),[_2],_4), _5 is _3/\_4, _6 is _5, _7 is _5, _8 is _6\/_7, warn_if_false(_8,'CP'). 'sift$cls'(A,B) :- sift_i(A,B). sift_i([],[]). sift_i([I|Is],[I|Ps]) :- remove(Is,I,New), sift_i(New,Ps). remove([],_1,[]). remove([I|Is],P,Nis) :- IModP is I mod P, IModP=0, !, remove(Is,P,Nis). remove([I|Is],P,[I|Nis]) :- remove(Is,P,Nis). intlist([]). intlist([X|Xs]) :- int(X), intlist(Xs).