A.3 library(apply): Apply predicates on a list
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(apply): Apply predicates on a list
          • include/3
          • exclude/3
          • partition/4
          • partition/5
          • maplist/2
          • maplist/3
          • maplist/4
          • maplist/5
          • convlist/3
          • foldl/4
          • foldl/5
          • foldl/6
          • foldl/7
          • scanl/4
          • scanl/5
          • scanl/6
          • scanl/7
    • Packages
Availability::- use_module(library(apply)).(can be autoloaded)
Sourcescanl(:Goal, +List, +V0, -Values)
scanl(:Goal, +List1, +List2, +V0, -Values)
scanl(:Goal, +List1, +List2, +List3, +V0, -Values)
scanl(:Goal, +List1, +List2, +List3, +List4, +V0, -Values)
Scan an ensemble of m (0 <= m <= 4) lists of length n head-to-tail ("scan-left"), using columns of m list elements as arguments for Goal. The scanl family of predicates is defined as follows, with V0 an initial value and V the final value of the scanning operation:
scanl(G, [X_11, ..., X_1n],
         [X_21, ..., X_2n],
         ...,
         [X_m1, ..., X_mn], V0, [V0, V1, ..., Vn] ) :-
   call(G, X_11, ..., X_m1, V0, V1),
   call(G, X_12, ..., X_m2, V1, V2),
   ...
   call(G, X_1n, ..., X_mn, V<n-1>, Vn).

scanl behaves like a foldl that collects the sequence of values taken on by the Vx accumulator into a list.