☰

*ON THIS PAGE*# Lazy evaluation library

**Author(s):** Amadeo Casas, Jose F. Morales.## Usage and interface

## Documentation on exports

*Meta-predicate* with arguments: `lazy_map(?,pred(2),?)`.

*Meta-predicate* with arguments: `lazy_foldr(pred(3),?,?,?)`.

*Meta-predicate* with arguments: `lazy_foldl(pred(3),?,?,?)`.

*Meta-predicate* with arguments: `zipWith(pred(3),?,?,?)`.

## Documentation on imports

This module has the following direct dependencies:

This module provides several predicates that make easier to develop predicates that will be executed lazily.

**Library usage:**`:- use_module(library(lazy/lazy_lib)).`**Exports:***Predicates:*`nums_from/2`,`nums_from_inc/3`,`repeat/2`,`cycle/2`,`take/3`,`takeWhile/3`,`drop/3`,`dropWhile/3`,`splitAt/3`,`span/3`,`tail/2`,`lazy_map/3`,`lazy_foldr/4`,`lazy_foldl/4`,`zipWith/4`.

PREDICATEnums_from/2

Usage:`nums_from(X,List)`

List is unified with an infinite list of successive numbers starting in X

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)X is currently a term which is not a free variable.

(`term_typing:var/1`)List is a free variable.

(`basic_props:int/1`)X is an integer.

(`term_typing:var/1`)List is a free variable.*The following properties should hold upon exit:*

(`basic_props:int/1`)X is an integer.

(`basic_props:list/2`)List is a list of ints.

PREDICATEnums_from_inc/3

Usage:`nums_from_inc(X,Y,List)`

List is unified with an infinite list of successive numbers starting in X with an increment of Y

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)X is currently a term which is not a free variable.

(`term_typing:nonvar/1`)Y is currently a term which is not a free variable.

(`term_typing:var/1`)List is a free variable.

(`basic_props:int/1`)X is an integer.

(`basic_props:int/1`)Y is an integer.

(`term_typing:var/1`)List is a free variable.*The following properties should hold upon exit:*

(`basic_props:int/1`)X is an integer.

(`basic_props:int/1`)Y is an integer.

(`basic_props:list/2`)List is a list of ints.

PREDICATErepeat/2

Usage:`repeat(X,List)`

List is unified with an infinite list of the term Y

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)X is currently a term which is not a free variable.

(`term_typing:var/1`)List is a free variable.

(`basic_props:term/1`)X is any term.

(`term_typing:var/1`)List is a free variable.*The following properties should hold upon exit:*

(`basic_props:term/1`)X is any term.

(`basic_props:list/2`)List is a list of terms.

PREDICATEcycle/2

Usage:`cycle(X,List)`

List is unified with an infinite list of the term Y repeated infinite times

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)X is currently a term which is not a free variable.

(`term_typing:var/1`)List is a free variable.

(`basic_props:term/1`)X is any term.

(`term_typing:var/1`)List is a free variable.*The following properties should hold upon exit:*

(`basic_props:term/1`)X is any term.

(`basic_props:list/2`)List is a list of terms.

PREDICATEtake/3

Usage:`take(X,ListA,ListR)`

ListR is unified with the first X elements of the infinite list ListA

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)X is currently a term which is not a free variable.

(`term_typing:nonvar/1`)ListA is currently a term which is not a free variable.

(`term_typing:var/1`)ListR is a free variable.

(`lazy_lib:counter/1`)X is a counter.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:term/1`)ListR is any term.*The following properties should hold upon exit:*

(`lazy_lib:counter/1`)X is a counter.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:list/2`)ListR is a list of terms.

PREDICATEtakeWhile/3

Usage:`takeWhile(P,ListA,ListR)`

ListR is unified with the first elements of the infinite list ListA while the condition P is true

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)P is currently a term which is not a free variable.

(`term_typing:nonvar/1`)ListA is currently a term which is not a free variable.

(`term_typing:var/1`)ListR is a free variable.

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:term/1`)ListR is any term.*The following properties should hold upon exit:*

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:list/2`)ListR is a list of terms.

PREDICATEdrop/3

Usage:`drop(X,ListA,ListR)`

ListR is unified with the infinite list ListA dropping the first X elements

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)X is currently a term which is not a free variable.

(`term_typing:nonvar/1`)ListA is currently a term which is not a free variable.

(`term_typing:var/1`)ListR is a free variable.

(`lazy_lib:counter/1`)X is a counter.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:term/1`)ListR is any term.*The following properties should hold upon exit:*

(`lazy_lib:counter/1`)X is a counter.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:list/2`)ListR is a list of terms.

PREDICATEdropWhile/3

Usage:`dropWhile(P,ListA,ListR)`

ListR is unified with the infinite list ListA dropping the first elements while the condition P is true

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)P is currently a term which is not a free variable.

(`term_typing:nonvar/1`)ListA is currently a term which is not a free variable.

(`term_typing:var/1`)ListR is a free variable.

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:term/1`)ListR is any term.*The following properties should hold upon exit:*

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:list/2`)ListR is a list of terms.

PREDICATEsplitAt/3

Usage:`splitAt(X,ListA,Res)`

Res is unified with a tuple of lists where the first list is composed by the first X elements of the list ListA and the second list is composed by the rest of the elements of ListA

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)X is currently a term which is not a free variable.

(`term_typing:nonvar/1`)ListA is currently a term which is not a free variable.

(`term_typing:var/1`)Res is a free variable.

(`lazy_lib:counter/1`)X is a counter.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:term/1`)Res is any term.*The following properties should hold upon exit:*

(`lazy_lib:counter/1`)X is a counter.

(`basic_props:list/2`)ListA is a list of terms.

(`lazy_lib:tuple_of_lists/1`)This type represents a tuple of lists.

PREDICATEspan/3

Usage:`span(P,ListA,Res)`

Res is unified with a tuple of lists where the first list is composed by the elements of ListA which verify the condition P and the second list is composed by the rest of the elements of the initial list

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)P is currently a term which is not a free variable.

(`term_typing:nonvar/1`)ListA is currently a term which is not a free variable.

(`term_typing:var/1`)Res is a free variable.

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:term/1`)Res is any term.*The following properties should hold upon exit:*

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:list/2`)ListA is a list of terms.

(`lazy_lib:tuple_of_lists/1`)This type represents a tuple of lists.

PREDICATEtail/2

Usage:`tail(ListA,ListR)`

ListR is unified with the tail of the infinite list ListA

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)ListA is currently a term which is not a free variable.

(`term_typing:var/1`)ListR is a free variable.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:term/1`)ListR is any term.*The following properties should hold upon exit:*

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:list/2`)ListR is a list of terms.

PREDICATElazy_map/3

Usage:`lazy_map(ListA,P,ListR)`

Version of the map/3 predicate to be executed lazily

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)ListA is currently a term which is not a free variable.

(`term_typing:nonvar/1`)P is currently a term which is not a free variable.

(`term_typing:var/1`)ListR is a free variable.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:term/1`)ListR is any term.*The following properties should hold upon exit:*

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:list/2`)ListR is a list of terms.

PREDICATElazy_foldr/4

Usage:`lazy_foldr(P,Xs,V0,V)`

Lazy version of `foldr/4`

*Call and exit should be compatible with:*

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:list/2`)Xs is a list of terms.

(`basic_props:term/1`)V0 is any term.

(`basic_props:term/1`)V is any term.*The following properties should hold at call time:*

(`term_typing:nonvar/1`)P is currently a term which is not a free variable.

(`term_typing:nonvar/1`)Xs is currently a term which is not a free variable.

(`term_typing:nonvar/1`)V0 is currently a term which is not a free variable.

(`term_typing:var/1`)V is a free variable.

PREDICATElazy_foldl/4

Usage:`lazy_foldl(P,Xs,V0,V)`

Lazy version of `foldl/4`

*Call and exit should be compatible with:*

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:list/2`)Xs is a list of terms.

(`basic_props:term/1`)V0 is any term.

(`basic_props:term/1`)V is any term.*The following properties should hold at call time:*

(`term_typing:nonvar/1`)P is currently a term which is not a free variable.

(`term_typing:nonvar/1`)Xs is currently a term which is not a free variable.

(`term_typing:nonvar/1`)V0 is currently a term which is not a free variable.

(`term_typing:var/1`)V is a free variable.

PREDICATEzipWith/4

Usage:`zipWith(P,ListA,ListB,ListR)`

ListR is a list whose elements are calculated from the function P and the elements of input lists ListA and ListB occuring at the same position in both lists

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)P is currently a term which is not a free variable.

(`term_typing:nonvar/1`)ListA is currently a term which is not a free variable.

(`term_typing:nonvar/1`)ListB is currently a term which is not a free variable.

(`term_typing:var/1`)ListR is a free variable.

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:list/2`)ListB is a list of terms.

(`basic_props:term/1`)ListR is any term.*The following properties should hold upon exit:*

(`basic_props:callable/1`)P is a term which represents a goal, i.e., an atom or a structure.

(`basic_props:list/2`)ListA is a list of terms.

(`basic_props:list/2`)ListB is a list of terms.

(`basic_props:list/2`)ListR is a list of terms.

*System library modules:*`freeze`,`arithpreds`.*Packages:*`prelude`,`initial`,`condcomp`,`regtypes`,`fsyntax`,`assertions`,`assertions/assertions_basic`,`basicmodes`,`hiord`,`lazy`.

Generated with LPdoc using Ciao