
separate_by_key(+Key, +Value, +All, -Matches, -Others)

   Partition the elements of a list according to a key value

Arguments
   Key                 Key argument position (positive integer, or list of those)
   Value               A term
   All                 List of structures
   Matches             Variable, or list of structures
   Others              Variable, or list of structures

Type
   library(lists_of_structures)

Description

    The list All is separated into two lists Matches and Others, such that
    Matches contains the elements whose Key argument is identical (in the
    sense of ==/2) to Value, and Others is a list with those matching elements
    deleted.  The original list does not have to be ordered.  The element
    order in the result lists corresponds to the order in the original list.
    

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

Exceptions
     4 --- Arguments are insufficiently instantiated
     5 --- Some argument or its components are of the wrong type
     6 --- Some structure does not have a Key'th argument

Examples
   
    ?- separate_by_key(1, b, [f(a,1),f(b,2),f(c,3),f(b,4)], Bs, Ns).
    Bs = [f(b,2), f(b,4)]
    Ns = [f(a,1), f(c,3)]
    Yes (0.00s cpu)


See Also
   same_key_prefix / 5, group_by_key / 3
