%program to insert an element in list domains A=symbol *. predicates addsym(A,symbol,integer,A). clauses addsym([],S,N,Q):- N<>0. addsym(P,S,N,[S|Q]):- N=0,!, addsym(P,S,-1,Q), write("inserted"). addsym([H|T],S,N,[H|Q]):- B=N-1, addsym(T,S,B,Q), write("ins").
Saturday, September 8, 2012
[PROLOG] How to insert an element in list?
Subscribe to:
Post Comments (Atom)