Re: Integer_division/3....stuck on the recursion part.
- From: sikkwanchu@xxxxxxxxxxx
- Date: 28 Nov 2005 09:02:58 -0800
NEFuchs wrote:
> Pierpaolo BERNARDI wrote:
> > sikkwanchu@xxxxxxxxxxx wrote:
> > > integer_division(_X,0,error).
> > >
> > > integer_division(0,_,_).
> >
> > ?
> >
> > > integer_division(X,Y,Z):-
> > > X >= Y,
> > > N is X - Y,
> > > integer_division(N,Y,A),
> > > Z = A + 1.
> > >
> > > im stuck in where the recurison ends.
> >
> > What's the result when X < Y ?
> >
> > Just add a clause which covers this case.
> >
> > P.
>
> Two further hints.
>
> 1. The clause "integer_division(0,_,_)" constitutes the base case of
> your recursion. What should be the result?
>
> 2. "Z = A + 1" unifies Z with A + 1, but does not assign the value of
> A + 1 to Z. Use the predicate is/2 for this purpose.
i got the second part.. but i dont get the first part still...since
when X is 0 then i return X,Y and Z as 0,_,Z or 0,_,_ or nothing even?
thx for the help
.
- Follow-Ups:
- Re: Integer_division/3....stuck on the recursion part.
- From: sikkwanchu
- Re: Integer_division/3....stuck on the recursion part.
- References:
- Integer_division/3....stuck on the recursion part.
- From: sikkwanchu
- Re: Integer_division/3....stuck on the recursion part.
- From: Pierpaolo BERNARDI
- Re: Integer_division/3....stuck on the recursion part.
- From: NEFuchs
- Integer_division/3....stuck on the recursion part.
- Prev by Date: Re: Integer_division/3....stuck on the recursion part.
- Next by Date: Re: Integer_division/3....stuck on the recursion part.
- Previous by thread: Re: Integer_division/3....stuck on the recursion part.
- Next by thread: Re: Integer_division/3....stuck on the recursion part.
- Index(es):
Relevant Pages
|
|