YAP 7.1.0
Extension of arg/3

More...

Detailed Description

An extension of arg/3 that supports backtracking through a term


Class Documentation

◆ genarg/3

class genarg/3

genarg( ?Index, +Term , -Arg )

Similar to arg/3 , but it can also backtrack through T's arguments, that is:

?- arg:genarg(I, f(a,b), A).
A = a,
I = 1.
;
A = b,
I = 2.

Note: SWI-Prolog defines arg/3 as genarg/3

◆ arg0/3

class arg0/3

arg0( +_Index_, +_Term_ , -_Arg_ )

  • Similar to arg/3 , but arg0(0,_T_,_F_) unifies F with T's principal functor:
?- arg0(0, f(a,b), A).
A = arg0.
?- arg0(1, f(a,b), A).
A = arg0.
?- arg0(2, f(a,b), A).
A = .
arg0( +_Index_, +_Term_ , -_Arg_ )

◆ genarg0/3

class genarg0/3

genarg0( +_Index_, +_Term_ , -_Arg_ )

  • Similar to genarg/3 , but genarg0(0,_T_,_F_) unifies F with T's principal functor:
    ?- genarg0(I,f(a,b),A).
    A = genarg0,
    I = 0 ? ;
    A = genarg0,
    I = 1 ? ;
    A = ,
    I = 2.
    genarg0( +_Index_, +_Term_ , -_Arg_ )

◆ args/3

class args/3

args( +_Index_, +_ListOfTerms_ , -_ListOfArgs_ )

  • Succeeds if ListOfArgs unifies with the application of genarg/3 to every element of ListOfTerms

It corresponds to calling maplist/3 on genarg/3 :

args( I, Ts, As) :-
maplist( genarg(I), Ts, As).
args( +_Index_, +_ListOfTerms_ , -_ListOfArgs_ )
maplist( 2:Pred, + List1,+ List2)

Notice that unification allows ListOfArgs to be bound, eg:

?- args(1, [X1+Y1,X2-Y2,X3*Y3,X4/Y4], [1,1,1,1]).
X1 = X2 = X3 = X4 = 1.

◆ args0/3

class args0/3

args0( +_Index_, +_ListOfTerms_ , -_ListOfArgs_ )

args0( +_ListOfTerms_ , +_Index_, -_ListOfArgs_ )

  • Succeeds if ListOfArgs unifies with the application of genarg0/3 to every element of ListOfTerms

It corresponds to calling maplist/3 on genarg0/3 :

args( I, Ts, As) :-
maplist( genarg0(I), Ts, As).

Notice that unification allows ListOfArgs to be bound, eg:

?- args(1, [X1+Y1,X2-Y2,X3*Y3,X4/Y4], [1,1,1,1]).
X1 = X2 = X3 = X4 = 1.
  • Succeeds if ListOfArgs unifies with the application of genarg0/3 to every element of ListOfTerms

It corresponds to calling args0/3 but with a different order

◆ path_arg/3

class path_arg/3

path_arg( +_Path_ , +_Term_, -_Arg_ )

  • Succeeds if Path is empty and Arg unifies with _Term, or if Path is a list with Head and Tail, genarg/3 succeeds on the current term, and path_arg/3 succeeds on its argument
  • Notice that it can be used to enumerate all possible paths in a term

Function Documentation

◆ Yap_InitInlines()

void Yap_InitInlines ( void  )

Definition at line 1194 of file inlines.c.

Functions

void Yap_InitInlines (void)