Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

please make the following prolog program
please make the following prolog  program

i hav try .but require result not come
my predicatelike this
plz find out mistake from it.




listtran([],[]).
listtran([Ha/Ta],[Hb/Tb]):-tran(Ha,Hb),listtran(Ta,Tb).

the given question is this:

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.

Report this thread to moderator Post Follow-up to this message
Old Post
naznadi@gmail.com
03-30-08 01:16 PM


Re: please make the following prolog program
naznadi@gmail.com wrote:
> please make the following prolog  program
>
> i hav try .but require result not come
> my predicatelike this
> plz find out mistake from it.
>
>
>
>
> listtran([],[]).
> listtran([Ha/Ta],[Hb/Tb]):-tran(Ha,Hb),listtran(Ta,Tb).
>
> the given question is this:
> [...]


you have a syntax error when constructing lists. just use the pipe
symbol | instead of slash / . if you google for "prolog lists" you will
find eg. http://www.csupomona.edu/~jrfisher/...torial/2_7.html
where the list syntax is described in more detail.

hth Martin

Report this thread to moderator Post Follow-up to this message
Old Post
Martin Riener
03-30-08 01:16 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Prolog archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:55 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.