For Programmers: Free Programming Magazines  


Home > Archive > Prolog > February 2006 > prolog









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author prolog
s26f84

2006-02-15, 7:00 pm

listtran(G,E):- tran(x,y).
listtran(G,E) :- listtran(G,E),tran(x,y).


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


hey guys the above given is a problem i am facing ... when i put 17 ?-
listtrans(G,one). it doesn't work... plz help

thanks

Erik Braun

2006-02-16, 3:58 am

s26f84 <mohit.akl@gmail.com> wrote:

> listtran(G,E):- tran(x,y).
> listtran(G,E) :- listtran(G,E),tran(x,y).

[...]

> hey guys the above given is a problem i am facing ... when i put 17 ?-
> listtrans(G,one). it doesn't work... plz help


You should »Learn Prolog Now!« This page will help you:
http://www.coli.uni-saarland.de/~kr...tml/node32.html

The way to the solution of your problem is explained there in detail,
especially section 4.3

Erik
a

2006-02-18, 7:56 am

Looks like a typo? You have a rule for listtran, but the query is for
listtrans.




s26f84 wrote:
> listtran(G,E):- tran(x,y).
> listtran(G,E) :- listtran(G,E),tran(x,y).
>
>
> 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).
>
>
> hey guys the above given is a problem i am facing ... when i put 17 ?-
> listtrans(G,one). it doesn't work... plz help
>
> thanks
>

a

2006-02-18, 6:58 pm

I didn't read carefully enough.... the following is also a problem ->
1. the listtran rule seems to be asking if tran(x,y) is a fact - which
it isn't
2. the resursive rule for listtran looks like it will exhaust stack space.

What is listtran intended to do?
tran(G,one) should succeed.



a wrote:[color=darkred]
> Looks like a typo? You have a rule for listtran, but the query is for
> listtrans.
>
>
>
>
> s26f84 wrote:
>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com