Re: for loop in prolog



% my_for(start_value,end_value,increment,action)
my_for(V,V,_,_) :- !.
my_for(Start,End,Inc,Action) :-
End > Start,
NewValue is Start+Inc,
call(Action),
my_for(NewValue,End,Inc,Action).

"nobody" <nobody@xxxxxxxxxxxxxx> escreveu na mensagem
news:pan.2006.01.10.19.29.18.959870@xxxxxxxxxxxxxxxxx
> 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...


.



Relevant Pages

  • Re: for loop in prolog
    ... > How could i implement a for loop in prolog. ... you'll have to ram them down people's throats." ... Prev by Date: ...
    (comp.lang.prolog)
  • 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: Non-recursive mod problem.
    ... Ok so what's happened is that I caught prolog in a loop because it was ... The only thing I want to ask now is why prolog chooses to increment Q ... goal so the last variable bound is Q so that's what gets ... Prev by Date: ...
    (comp.lang.prolog)
  • RE: insert while
    ... > NewValue, DateModified, domainuser) ... > query works except, on the second run through the while loop, there are now ... > inserts three on the next loop and so on and so on. ...
    (microsoft.public.sqlserver.programming)
  • Re: Lists do not work
    ... >>% for breaking out of the loop ... There's something missing here. ... I wrote that I'm new to Prolog and I have really no clue why this should ... > Your Prolog has no syntax error, ...
    (comp.lang.prolog)