Changeset 4089 for trunk/library

Show
Ignore:
Timestamp:
02/15/08 04:02:58 (11 months ago)
Author:
pmoura
Message:

Updated the library object "loop" to allow arithmetic expressions as arguments in the forto/3-4 and fordownto/3-4 predicates for convenience and clarity.

Location:
trunk/library
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/library/loop.lgt

    r3694 r4089  
    44 
    55    :- info([ 
    6         version is 1.1, 
     6        version is 1.2, 
    77        author is 'Paulo Moura', 
    8         date is 2006/9/17, 
     8        date is 2008/2/15, 
    99        comment is 'Loop control structures predicates.']). 
    1010 
     
    2323 
    2424    :- meta_predicate(forto(*, *, ::)). 
    25     forto(First, Last, Call) :- 
     25    forto(FirstExp, LastExp, Call) :- 
     26        First is FirstExp, 
     27        Last is LastExp, 
    2628        (   First =< Last -> 
    2729            \+ \+ call(Call), 
     
    3234 
    3335    :- meta_predicate(forto(*, *, *, ::)). 
    34     forto(Count, First, Last, Call) :- 
     36    forto(Count, FirstExp, LastExp, Call) :- 
     37        First is FirstExp, 
     38        Last is LastExp, 
    3539        (   First =< Last -> 
    3640            \+ \+ (Count = First, call(Call)), 
     
    4145 
    4246    :- meta_predicate(fordownto(*, *, ::)). 
    43     fordownto(First, Last, Call) :- 
     47    fordownto(FirstExp, LastExp, Call) :- 
     48        First is FirstExp, 
     49        Last is LastExp, 
    4450        (   First >= Last -> 
    4551            \+ \+ call(Call), 
     
    5056 
    5157    :- meta_predicate(fordownto(*, *, *, ::)). 
    52     fordownto(Count, First, Last, Call) :- 
     58    fordownto(Count, FirstExp, LastExp, Call) :- 
     59        First is FirstExp, 
     60        Last is LastExp, 
    5361        (   First >= Last -> 
    5462            \+ \+ (Count = First, call(Call)), 
  • trunk/library/loopp.lgt

    r3688 r4089  
    33 
    44    :- info([ 
    5         version is 1.1, 
     5        version is 1.2, 
    66        author is 'Paulo Moura', 
    7         date is 2006/9/17, 
    8         comment is 'Loop control structures protocol.']). 
     7        date is 2008/2/15, 
     8        comment is 'Loop control constructs protocol.']). 
    99 
    1010    :- public(dowhile/2). 
     
    1919    :- mode(forto(+integer, +integer, @callable), zero_or_one). 
    2020    :- info(forto/3, [ 
    21         comment is 'Counting from First to Last do Call.', 
     21        comment is 'Counting from First to Last do Call. For convenience and clarity, First and Last can be arithmetic expressions.', 
    2222        argnames is ['First', 'Last', 'Call']]). 
    2323 
     
    2626    :- mode(forto(-integer, +integer, +integer, @callable), zero_or_one). 
    2727    :- info(forto/4, [ 
    28         comment is 'Do Call counting from First to Last and instantiating Count to each sucessive value.', 
     28        comment is 'Do Call counting from First to Last and instantiating Count to each successive value. For convenience and clarity, First and Last can be arithmetic expressions.', 
    2929        argnames is ['Count', 'First', 'Last', 'Call']]). 
    3030 
     
    3333    :- mode(fordownto(+integer, +integer, @callable), zero_or_one). 
    3434    :- info(fordownto/3, [ 
    35         comment is 'Counting from First to Last do Call.', 
     35        comment is 'Counting from First to Last do Call. For convenience and clarity, First and Last can be arithmetic expressions.', 
    3636        argnames is ['First', 'Last', 'Call']]). 
    3737 
     
    4040    :- mode(fordownto(-integer, +integer, +integer, @callable), zero_or_one). 
    4141    :- info(fordownto/4, [ 
    42         comment is 'Do Call counting from First to Last and instantiating Count to each sucessive value.', 
     42        comment is 'Do Call counting from First to Last and instantiating Count to each successive value. For convenience and clarity, First and Last can be arithmetic expressions.', 
    4343        argnames is ['Count', 'First', 'Last', 'Call']]). 
    4444