I Tried to write a simple code in Prolog which translate a list to another list. for instance, if we call listtrans([a,b,c],L)
, L
will become [1,2,3]
. (a,b,c is replaced with 1,2,3). But i faced with a syntax error in last line. what is the problem? here is my code:
trans(a,1).
trans(b,2).
trans(c,3).
listtrans([],L).
listtrans([H|T],L1):-
trans(H,B),
append(B,L,L2),
listtrans(T,L2).