YAP 7.1.0
Map List and Term Operations

More...

Detailed Description

Modules

 Apply Interface to maplist
 This library provides a SWI-compatible set of utilities for applying a predicate to all elements of a list.
 

Class Documentation

◆ maplist/3

class maplist/3

maplist( 2:Pred, + List1,+ List2)

maplist(: Pred, ? L1, ? L2 )

Apply Pred on all successive pairs of elements from List1 and List2 Fails if Pred can not be applied to a pair See the example above

L1 and L2 are such that call( _Pred_, _A1_, _A2_) holds for every corresponding element in lists L1, L2

Comment from Richard O'Keefe: succeeds when Pred( _Old, New) succeeds for each corresponding Gi in Listi, New in NewList In InterLisp, this is MAPCAR It is also MAP2C Isn't bidirectionality wonderful?

◆ maplist/4

class maplist/4

maplist(3:Pred,+ List1,+ List2,+ List4)

maplist(: Pred, ? L1, ? L2, ? L3)

Apply Pred on all successive triples of elements from List1, List2 and List3 Fails if Pred can not be applied to a triple See the example above

L1, L2, and L3 are such that call( _Pred_, _A1_, _A2_, _A3_) holds for every corresponding element in lists L1, L2, and L3

◆ include/3

class include/3

include( 2:Pred, + ListIn, ? ListOut)

Same as selectlist/3

◆ selectlist/3

class selectlist/3

selectlist(1:Pred, + ListIn, ? ListOut)

)

Creates ListOut of all list elements of ListIn that pass a given test

◆ selectlist/5

class selectlist/5

selectlist( 2:Pred, + ListIn, + ListInAux, ? ListOut, ? ListOutAux)

Creates ListOut and ListOutAux of all list elements of ListIn and ListInAux that pass the given test Pred

◆ selectlist/4

class selectlist/4

selectlist( 2:Pred, + ListIn, + ListInAux, ? ListOut)

Creates ListOut of all list elements of ListIn that pass the given test Pred using + ListInAux as an auxiliary element

◆ exclude/3

class exclude/3

exclude( 2:Goal, + List1, ? List2)

Filter elements for which Goal fails True if List2 contains those elements Xi of List1 for which call(Goal, Xi) fails

◆ partition/4

class partition/4

partition(1:Pred, + List1, ? Included, ? Excluded)

Filter elements of List1 according to Pred True if Included contains all elements for which call(Pred, X) succeeds and Excluded contains the remaining elements

◆ partition/5

class partition/5

partition(2:Pred, + List1, ? Lesser, ? Equal, ? Greater)

Filter list according to Pred in three sets For each element Xi of List, its destination is determined by call(Pred, Xi, Place), where Place must be unified to one of \<, = or \> Pred must be deterministic

◆ checklist/2

class checklist/2

checklist( 1:Pred, + List)

Succeeds if the predicate Pred succeeds on all elements of List

◆ maplist/5

class maplist/5

maplist(: Pred, ? L1, ? L2, ? L3, ? L4)

L1, L2, L3, and L4 are such that call( _Pred_, _A1_, _A2_, _A3_, _A4_) holds for every corresponding element in lists L1, L2, L3, and L4

◆ maplist/6

class maplist/6

maplist(: Pred, ? L1, ? L2, ? L3, ? L4, ? L5)

L1, L2, L3, L4 and L5 are such that call( _Pred_, _A1_, _A2_, _A3_, _A4_,_A5_) holds for every corresponding element in lists L1, L2, L3, L4 and L5

◆ convlist/3

class convlist/3

convlist(: Pred, + ListIn, ? ListOut)

A combination of maplist/3 and selectlist/3 : creates ListOut by applying the predicate Pred to all list elements on which Pred succeeds

ROK: convlist(Rewrite, OldList, NewList) is a sort of hybrid of maplist/3 and sublist/3 Each element of NewList is the image under Rewrite of some element of OldList, and order is preserved, but elements of OldList on which Rewrite is undefined (fails) are not represented Thus if foo(X,Y) :- integer(X), Y is X+1 then convlist(foo, [1,a,0,joe(99),101], [2,1,102])

◆ convlist/4

class convlist/4

convlist(: Pred, ? ListIn, ?ExtraList, ? ListOut)

A combination of maplist/4 and selectlist/3 : ListIn, ListExtra, and ListOut are the sublists so that the predicate Pred succeeds

ROK: convlist(Rewrite, OldList, NewList) is a sort of hybrid of maplist/3 and sublist/3 Each element of NewList is the image under Rewrite of some element of OldList, and order is preserved, but elements of OldList on which Rewrite is undefined (fails) are not represented Thus if foo(X,Y) :- integer(X), Y is X+1 then convlist(foo, [1,a,0,joe(99),101], [2,1,102])

◆ mapnodes/3

class mapnodes/3

mapnodes(+ Pred, + TermIn, ? TermOut)

Creates TermOut by applying the predicate Pred to all sub-terms of TermIn (depth-first and left-to-right order)

◆ checknodes/2

class checknodes/2

checknodes(+ Pred, + Term)


Succeeds if the predicate Pred succeeds on all sub-terms of Term (depth-first and left-to-right order)

◆ sumlist/4

class sumlist/4

sumlist(: Pred, + List, ? AccIn, ? AccOut)

Calls Pred on all elements of List and collects a result in Accumulator Same as fold/4

◆ sumnodes/4

class sumnodes/4

sumnodes(+ Pred, + Term, ? AccIn, ? AccOut)

Calls the predicate Pred on all sub-terms of Term and collect a result in Accumulator (depth-first and left-to-right order)

◆ foldl/6

class foldl/6

foldl(:Goal, +List, +V0, -V, +W0, -WN)

foldl(Goal, List1, List2, List3, V0, V)

%

Apply Goal plus five arguuments, three map to lists, two can be used as a difference_type

◆ oldl/5

class oldl/5

oldl(: Pred, + List1, + List2, ? AccIn, ? AccOut)

The foldl family of predicates is defined

foldl(P, [X11,...,X1n],V0, Vn, W0, WN) :- P(X11, V0, V1, W0, W1), ...

P(X1n, Vn1, Vn, Wn1, Wn).

Calls Pred on all elements of List1 and collects a result in Accumulator Same as foldr/3

◆ foldl/5

class foldl/5

foldl(: Pred, + List1, + List2, ? AccIn, ? AccOut)

Calls Pred on all elements of List1 and List2 and collects a result in Accumulator Same as foldr/4

◆ foldl2/6

class foldl2/6

foldl2(: Pred, + List, ? X0, ? X, ? Y0, ? Y)

Calls Pred on all elements of List and collects a result in X and Y

◆ foldl2/7

class foldl2/7

v

foldl2(: Pred, + List, ? List1, ? X0, ? X, ? Y0, ? Y)

Calls Pred on all elements of List and List1 and collects a result in X and Y

◆ foldl2/8

class foldl2/8

foldl2(: Pred, + List, ? List1, ? List2, ? X0, ? X, ? Y0, ? Y)

Calls Pred on all elements of List, List1 and List2 and collects a result in X and Y

◆ foldl3/9

class foldl3/9

foldl3(: Pred, + List1, ? List2, ? X0, ? X, ? Y0, ? Y, ? Z0, ? Z)

Calls Pred on all elements of List and collects a result in X, Y and Z

◆ foldl4/11

class foldl4/11

foldl4(: Pred, + List1, ? List2, ? X0, ? X, ? Y0, ? Y, ? Z0, ? Z, ? W0, ? W)

Calls Pred on all elements of List and collects a result in X, Y, Z and W