Re: for loop in prolog



nobody wrote:
hi to all,

How could i implement a for loop in prolog. Let's say for
example that i have an integer variable X and i want to repeat X times a specific action. Any idea welcome...


?- between(1, 5, X), write(X), nl, fail.
1
2
3
4
5

No

% The fail/0 prevents my prolog processor from asking for each X
% whether to continue or not.

Roland
.



Relevant Pages

  • for loop in prolog
    ... How could i implement a for loop in prolog. ... example that i have an integer variable X and i want to repeat X ... Prev by Date: ...
    (comp.lang.prolog)
  • Re: it will cautiously hand likely and merges our bottom, absent accountants in respect of a hardwar
    ... Nobody outside specialise occupational and reveals our governing, ... mixed commands past a charter. ... it'll actually repeat the pencil. ... Nobody fatally arrange at least eager nursing tours. ...
    (sci.crypt)
  • Re: A Class of Non-Halting TMs
    ... >> Step, current state, input, and tape position. ... and so it will loop forever" may not be true. ... if you take a nonhalting machine history which eventually ... My method will say steps 7-8 repeat: ...
    (comp.theory)
  • Re: RFC: About error handling - WAS: Re: A remobjects wtf...
    ... Of course in this example (and probably in most cases, as there is some condition that determines whether you need to retry) it could be replaced with a test for a valid BaudRate in 'until'. ... You could be against repeat and while in general with the same argument. ... I would also say that your 'Retry' examples resembles these much more (You wouldn't need 'goto Succeeded', would you?): ... 'break') applies to this 'fake' loop, ...
    (borland.public.delphi.non-technical)
  • Re: Using variables
    ... This code mostly avoids stack gymnastics by using the pseudoregisters p and q for the addresses, representing data whose flow isn't LIFO. ... We could use v-v-dot as a factor, but here we can save some address arithmetic in the outer loop by noting that if p contains the address of a matrix, after iterating it points to the next row of the matrix automatically. ... they use LSE's beloved universal loop word: "repeat". ... you sometimes need to break out of an "iterate" loop prematurely. ...
    (comp.lang.forth)