[ Reference Manual | Alphabetic Index ]

library(lists_of_structures)

Operations on lists of structures   [more]

Predicates

args(+Key, +Structs, -Args)
Extract arguments from a list of structures
group_by_key(+Key, +Structs, -Grouped)
Partition a list into sublists by key
group_with_key(+Key, +Structs, -Grouped)
Partition a list into sublists by key
inserta(+Key, +Struct, +Old, -New)
Insert Struct into a sorted list
insertz(+Key, +Struct, +Old, -New)
Insert Struct into a sorted list
lists_structs(?Lists, ?Structs)
Mapping between a structure of lists and a list of structures
same_key_prefix(+Key, +All, -KeyVal, -Prefix, -Rest)
Get the maximum prefix of a list with identical key values
separate_by_key(+Key, +Value, +All, -Matches, -Others)
Partition the elements of a list according to a key value
terms_functor(?Structs, ?Length, ?Name, ?Arity)
All list elements have the given functor or atomic value
update(+Key, +Struct, +Old, -New)
Incorporate Struct into a duplicate-free sorted list

Description

This library contains predicates that operate on lists of structures, in particular structures where one argument can be considered a `key'. Such lists are very common, and often occur in sorted form.

The ECLiPSe kernel and other libraries support such lists as well, e.g.

If you have declared your structures using the :- local(struct(...)) declaration, then you can use field names to identify the key arguments in all these predicates, e.g.

    :- local struct(emp(name,age,salary)).

    ?- Emps = [emp{name:joe,salary:100}, emp{name:bob,salary:200}],
       sort(salary of emp, >=, Emps, Descending),
       args(name of emp, Descending, Names).

    Emps = [emp(joe, _, 100), emp(bob, _, 200)]
    Descending = [emp(bob, _, 200), emp(joe, _, 100)]
    Names = [bob, joe]
    yes

About

See Also

hash : list_to_hash / 4, sort / 4, merge / 5, struct / 1
Generated from lists_of_structures.eci on 2017-08-19 21:59