Re: Another little problem
- From: Thorsten Kiefer <toki782@xxxxxxxxxxxxxxxx>
- Date: Mon, 26 Feb 2007 23:45:56 +0100
phantastic@xxxxxxxxxx wrote:
repeat
h(Z,F,G)
F = G
G = Z
while Z <> empty
Hi,
in I think in prolog you have to convert this into recursion.
Which variable holds the result of your computation ? F,G or Z ?
Z makes no sens, as it is [] at the end.
G also makes no sense as it is G := Z at the end.
So I think it is F, right ?
So how about this:
pred(F,F,G) :- h([],F,G).
pred(Fout,F,G) :-
h(Z,F,G),
pred(Fout,G,Z).
Regards
Thorsten
.
- Follow-Ups:
- Re: Another little problem
- From: phantastic
- Re: Another little problem
- References:
- Another little problem
- From: phantastic
- Another little problem
- Prev by Date: Re: comp.lang.prolog FAQ transfer
- Next by Date: Prolog as a scripting language
- Previous by thread: Re: Another little problem
- Next by thread: Re: Another little problem
- Index(es):
Relevant Pages
|
|