Solved Re: Translating a list of numbers



On Jan 20, 5:24 pm, Cesar Rabak <csra...@xxxxxxxxxxxx> wrote:
Slobodan Blazeski escreveu:> 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:

[snipped]

Since you're learning:

Hint: to answer this question, first ask yourself 'How do I translate
the empty list of
number words?'.

What's your answer to this question?

That's the base case. For non-empty lists, first
translate the head of
the list, then use recursion to translate the tail.

Then proceed with this suggestion.
Solved, thanks for your help.

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).

listtran([],[]).
listtran([Hg|Tg],[He|Te]) :-
tran(Hg,He),
listtran(Tg,Te).

cheers
Slobodan
.



Relevant Pages

  • 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: Lets IGNORE Lymeraja
    ... > I think he ought to improve his English before he tries to get stuck ... Y thinc my Inglizh is quit goot, so Y whon't asc Frank two translate. ...
    (sci.med.diseases.lyme)
  • Translate C expression to Java expression
    ... I'm attempting to translate a C function to a Java method, ... but I'm stuck on the two non-trivial return expressions shown below. ...
    (comp.lang.java.help)
  • Re: Does this make any sense?
    ... > My own experience learning japanese is that I would rather have ... > someone translate it for me, rather than being stuck for months. ... If you're stuck for months, ... Ever heard the old thing about giving a man a fish vs. teaching him how to fish? ...
    (sci.lang.japan)
  • Re: Direct computation of integer limits in K&R2?
    ... translate the exercise in English here ... Write a program to determine the value ranges of the variable types char, short, int, and long, both for signed and the unsigned ones, displaying the appropriate values from the standard headers, and by direct calculation. ...
    (comp.lang.c)