Re: Why does this recursion not work?
- From: student <nospam@xxxxxxxxxxxxxx>
- Date: Mon, 18 Apr 2005 23:59:11 GMT
Anders Lindén wrote:
%to get the tail of the sequence
tail(sekv(D,T),T).
%find the last element:
last(nil,nil).
last(sekv(D,nil),D). %only one element left
%the recursion
last(sekv(D,R),R2):- last(tail(R,R2),R2).
Why does this recursion not work?
To save ink, I will replace your 'sekv' functor with the single-letter functor 'd'.
What is the "tail" and what is the "last elment" in each of these cases:
nil
d(X,Y)
d(a,d(X,Y))
d(a,d(X,d(Y,nil))) .
- References:
- Why does this recursion not work?
- From: Anders Lindén
- Why does this recursion not work?
- Prev by Date: Re: Why does this recursion not work?
- Next by Date: Looking for "diff" algorithm.
- Previous by thread: Re: Why does this recursion not work?
- Next by thread: Looking for "diff" algorithm.
- Index(es):