Commit Graph

2 Commits

Author SHA1 Message Date
Zoltan Somogyi
9473b939d7 Add more functionality to ra_list.m.
The changes to cord.m and list.m are to reduce unnecessary differences
between cord.m, list.m, and ra_list.m.

library/ra_list.m:
    Add new procedures singleton, is_empty, is_not_empty, is_singleton,
    length, list_to_ra_list, map, foldl and foldr.

    Make ra_list_to_list operate without unnecessary memory allocations.

library/cord.m:
    Add a semidet predicate head as a synonym for get_first.

library/list.m:
    Add a semidet predicate is_singleton.

    Add semidet predicates head and tail next to their semidet function
    versions (which should be deprecated). Document them.

    Add det predicates det_head and det_tail next to their det function
    versions.

    Avoid the overhead of calling a closure used for func-to-pred conversion
    once for each list element in the function versions of foldl and foldr.

    Fix some other documentation.

NEWS:
    Mention the new additions to standard library.

library/term_to_xml.m:
tests/hard_coded/construct_packed.m:
    Avoid ambiguities between function and predicate forms.

tests/hard_coded/ra_list_test.{m,exp}:
    Add tests of length, list_to_ra_list, map, foldl and foldr.
2022-06-12 19:42:47 +10:00
Zoltan Somogyi
3459266a7a Carve stdlib module ra_list.m out of bt_array.m.
library/ra_list.m:
    As above.

    Rename ra_list_lookup to ra_list_search, since it fails if the item
    to be accessed does not exist. Add a version, ra_list_lookup, which
    aborts in that case.

    Add predicates to append two ra_lists, and to convert ra_lists
    to just plain lists.

    Change the argument order of some predicates to be more
    state variable friendly.

    Add some documentation.

library/bt_array.m:
    Delete the moved code, and update the references to the changed predicates.

library/Mercury.options:
    Now that the ra_list predicates have been moved to their own module,
    stop giving bt_array.m a free pass on inconsistent predicate order.

library/MODULES_DOC:
library/library.m:
    Add ra_list.m as a documented module of the Mercury standard library.

library/array.m:
    Delete a predicate that served as a test for an ancient bug fix.

NEWS:
    Announce both the new ra_list module, and the deletion of the predicate
    from array.m.

tests/hard_coded/array_sort.m:
    Don't call the predicate deleted from array.m.

tests/hard_coded/ra_list_test.{m,exp}:
    A new test case to test operations on ra_lists.

tests/hard_coded/Mmakefile:
    Enable the new test case.
2022-06-11 11:11:30 +10:00