Solved Re: Translating a list of numbers
- From: Slobodan Blazeski <slobodan.blazeski@xxxxxxxxx>
- Date: Sun, 20 Jan 2008 08:58:14 -0800 (PST)
On Jan 20, 5:24 pm, Cesar Rabak <csra...@xxxxxxxxxxxx> wrote:
Slobodan Blazeski escreveu:> Hi groupSolved, thanks for your help.
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.
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
.
- References:
- Translating a list of numbers
- From: Slobodan Blazeski
- Re: Translating a list of numbers
- From: Cesar Rabak
- Translating a list of numbers
- Prev by Date: Re: Translating a list of numbers
- Next by Date: Re: Translating a list of numbers
- Previous by thread: Re: Translating a list of numbers
- Next by thread: Re: Translating a list of numbers
- Index(es):
Relevant Pages
|