Translating a list of numbers



Hi group

I'm common lisp programmer that started learning prolog this thursday.
I'm using book learn prolog now, nice book but lacks solutions for
selfstudy, and everything was going smooth untill I got stuck at
Exercise 4.2. I really can not think of any way how to make the
translation and that frustrates me. Any help for this task or show me
something simigliar like how to use translating fact into unification
will be highly appreciated?

thanks
Slobodan

Exercise 4.2 Suppose we are given a knowledge base with the following
facts:
tran(eins,one).
tran(zwei,two).
tran(drei,three).
tran(vier,four).
tran(fuenf,five).
tran(sechs,six).
tran(sieben,seven).
tran(acht,eight).
tran(neun,nine).
Write a predicate listtran(G,E) which translates a list of German
number words to
the corresponding list of English number words. For example:
listtran([eins,neun,zwei],X).
should give:
X = [one,nine,two].
Your program should also work in the other direction. For example, if
you give it the
query
listtran(X,[one,seven,six,two]).
it should return:
X = [eins,sieben,sechs,zwei].
Hint: to answer this question, first ask yourself 'How do I translate
the empty list of
number words?'. That's the base case. For non-empty lists, first
translate the head of
the list, then use recursion to translate the tail.
.



Relevant Pages

  • Re: Translating a list of numbers
    ... I'm common lisp programmer that started learning prolog this thursday. ... translate the rest of the list. ... For non-empty lists, first ...
    (comp.lang.prolog)
  • Re: Translating a list of numbers
    ... I'm common lisp programmer that started learning prolog this thursday. ... first ask yourself 'How do I translate ... For non-empty lists, first ...
    (comp.lang.prolog)
  • Re: substitue for LISTS and TUPLEs in C++
    ... Depending on exactly what operations you plan to do with it, the Python ... list will translate into some kind of STL sequence container like vector. ... Tuples in Python are sometimes used like ummutable lists, ... anonymous fixed-length heterogeneous data structures, ...
    (comp.lang.python)
  • Re: Translating a list of numbers
    ... I'm common lisp programmer that started learning prolog this thursday. ... something simigliar like how to use translating fact into unification ... Exercise 4.2 Suppose we are given a knowledge base with the following ... then use recursion to translate the tail. ...
    (comp.lang.prolog)
  • Re: Any leak in my first macro? :)
    ... For an app I'm trying to do, I need to translate a list of notes in a ... `(or,@(loop for lst in lists collect ...
    (comp.lang.lisp)