Search code examples
prologmachine-translation

How do you program a translator with lists in prolog?


What I want to do is a translator in Prolog. I've done something like this to translate one word:

traducir(X,Y) :- traduccion( X, Y ).
traduccion(gato,cat).

And when you ask Prolog traducir(X,cat) , it answers X=gato What I want to do is a translator where you ask something like traducir(X,[Hola,mi,nombre,es,Juan]). and Prolog's answer should be X=[Hello,my,name,is,John].


Solution

  • Here is another one :

    traducir(Xs, Ys) :- maplist(traduccion, Xs, Ys).