Re: how to make a list of N 1s
- From: "erhan" <eerisken@xxxxxxxxxx>
- Date: 26 Apr 2006 23:28:38 -0700
makeOnes(0,[]).
makeOnes(N,[1|T]) :- N1 is N-1, makeOnes(N1,T).
this does not work, when I say makeones(3,L), it finds L=[1,1,1], but
if I say find another solution by typing ";" it enters into a infinite
loop...
but a slight modification make it work. here it is:
makeOnes(0,[]) :- !.
makeOnes(N,[1|T]) :- N1 is N-1, makeOnes(N1,T).
anyway, thank you very much...
.
- Follow-Ups:
- Re: how to make a list of N 1s
- From: michael . goodrich
- Re: how to make a list of N 1s
- References:
- how to make a list of N 1s
- From: erhan
- Re: how to make a list of N 1s
- From: michael . goodrich
- how to make a list of N 1s
- Prev by Date: Re: how to make a list of N 1s
- Next by Date: Re: how to make a list of N 1s
- Previous by thread: Re: how to make a list of N 1s
- Next by thread: Re: how to make a list of N 1s
- Index(es):