root/tags/lgt2310/library/loop.lgt

Revision 3694, 1.2 KB (checked in by pmoura, 20 months ago)

Corrected wrong order of meta_predicate/1 directives.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 
2:- object(loop,
3    implements(loopp)).
4
5    :- info([
6        version is 1.1,
7        author is 'Paulo Moura',
8        date is 2006/9/17,
9        comment is 'Loop control structures predicates.']).
10
11    :- meta_predicate(whiledo(::, ::)).
12    whiledo(Condition, Action) :-
13        (   call(Condition) ->
14            \+ \+ call(Action),
15            whiledo(Condition, Action)
16        ;   true
17        ).
18
19    :- meta_predicate(dowhile(::, ::)).
20    dowhile(Action, Condition) :-
21        \+ \+ call(Action),
22        whiledo(Condition, Action).
23
24    :- meta_predicate(forto(*, *, ::)).
25    forto(First, Last, Call) :-
26        (   First =< Last ->
27            \+ \+ call(Call),
28            Next is First + 1,
29            forto(Next, Last, Call)
30        ;   true
31        ).
32
33    :- meta_predicate(forto(*, *, *, ::)).
34    forto(Count, First, Last, Call) :-
35        (   First =< Last ->
36            \+ \+ (Count = First, call(Call)),
37            Next is First + 1,
38            forto(Count, Next, Last, Call)
39        ;   true
40        ).
41
42    :- meta_predicate(fordownto(*, *, ::)).
43    fordownto(First, Last, Call) :-
44        (   First >= Last ->
45            \+ \+ call(Call),
46            Next is First - 1,
47            fordownto(Next, Last, Call)
48        ;   true
49        ).
50
51    :- meta_predicate(fordownto(*, *, *, ::)).
52    fordownto(Count, First, Last, Call) :-
53        (   First >= Last ->
54            \+ \+ (Count = First, call(Call)),
55            Next is First - 1,
56            fordownto(Count, Next, Last, Call)
57        ;   true
58        ).
59
60:- end_object.
Note: See TracBrowser for help on using the browser.