newbie: Out of local stack, matching values from 0 to 10
- From: Matthijs Wensveen <mrw@xxxxxxxxxx>
- Date: Mon, 23 May 2005 03:15:00 +0200
Hi,
I recently started programmin in prolog again, just for fun. But immediately I encountered some major problems.
I am trying to have prolog match any value from 0 to 10.
What I have written so far:
---
in_bounds(0).
in_bounds(X) :- in_bounds(Y), X is Y + 1, X < 10. ---
When I query in_bounds(X). all the values from 0 to and including 9 are matched, but then it says "ERROR: Out of local stack".
I think I understand why, but I can't think of another way to do this.
Actually I do:
in_bounds(X) :- member(X, [0,1,2,3,4,5,6,7,8,9]).
But this seems rather tedious.
Secondly, is there a shorthand for lists like this? I would like to be able to write [1..10] or [1,..,10] or so.
I'm using SWI-Prolog.
Thanks, Matthijs. .
- Follow-Ups:
- Re: newbie: Out of local stack, matching values from 0 to 10
- From: Jan Wielemaker
- Re: newbie: Out of local stack, matching values from 0 to 10
- Prev by Date: Re: deductive databases
- Next by Date: Re: newbie: Out of local stack, matching values from 0 to 10
- Previous by thread: double_quotes doesnt return codes in SWI-Prolog
- Next by thread: Re: newbie: Out of local stack, matching values from 0 to 10
- Index(es):