
args(+Key, +Structs, -Args)

   Extract arguments from a list of structures

Arguments
   Key                 Key argument position (positive integer, or list of those)
   Structs             List of structures
   Args                Variable, or list of arguments

Type
   library(lists_of_structures)

Description

    Structs is a list of structures, and Args is a list of the Key'th
    arguments of these structures.
    
    This is equivalent to either

    maplist(arg(Key), Structs, Args)

    or

    ( foreach(S,Structs), foreach(A,Args), param(Key) do arg(Key,S,A) )

    

Modes and Determinism
   args(+, +, -) is det

Exceptions
     4 --- Structs is insufficiently instantiated
     6 --- Some structure in Structs does not have a Key'th argument

Examples
   
    ?- args(2, [f(3,a),f(2,b),f(1,c)], Args).
    Args = [a,b,c]
    yes

    % extract keys from pairs
    ?- args(1, [a-1,a-2,b-2,c-2,c-5], Keys).
    Keys = [a,a,b,c,c]
    yes

    % extract values from pairs
    ?- args(2, [a-1,a-2,b-2,c-2,c-5], Values).
    Values = [1,2,2,2,5]
    yes


See Also
   arg / 3
