List processing

Author(s): The Ciao Development Team.

This module provides a set of predicates for list processing.

Documentation on exports

PREDICATEnonsingle/1

Usage:nonsingle(X)

X is not a singleton.

    PREDICATEappend/3

    Usage:append(Xs,Ys,Zs)

    Other properties:
    append(Xs,Ys,Zs)

    Zs is Ys appended to Xs.

    append(Xs,Ys,Zs)

    append(Xs,Ys,Zs)

    append(Xs,Ys,Zs)

    • The following properties should hold upon exit:
      (native_props:mshare/2)The sharing pattern for the variables [Xs,Ys,Zs] is [[Xs,Ys,Zs],[Xs,Zs],[Ys,Zs]].
    append(Xs,Ys,Zs)

    • If the following properties hold at call time:
      (term_typing:ground/1)Xs is currently ground (it contains no variables).
      (term_typing:ground/1)Ys is currently ground (it contains no variables).
      then the following properties should hold upon exit:
      (term_typing:ground/1)Zs is currently ground (it contains no variables).
    append(Xs,Ys,Zs)

    • If the following properties hold at call time:
      (term_typing:ground/1)Zs is currently ground (it contains no variables).
      then the following properties should hold upon exit:
      (term_typing:ground/1)Xs is currently ground (it contains no variables).
      (term_typing:ground/1)Ys is currently ground (it contains no variables).
    append(Xs,Ys,Zs)

    • The following properties hold globally:
      (basic_props:sideff/2)append(Xs,Ys,Zs) is side-effect free.
    append(Xs,Ys,Zs)

    • If the following properties hold at call time:
      (basic_props:list/1)Xs is a list.
      then the following properties hold globally:
      (basic_props:eval/1)append(Xs,Ys,Zs) is evaluable at compile-time.
    append(Xs,Ys,Zs)

    • If the following properties hold at call time:
      (basic_props:list/1)Zs is a list.
      then the following properties hold globally:
      (basic_props:eval/1)append(Xs,Ys,Zs) is evaluable at compile-time.

    PREDICATEreverse/2

    Usage:reverse(Xs,Ys)

    Reverses the order of elements in Xs.

    Other properties:

    • The following properties hold globally:
      (basic_props:sideff/2)reverse(Arg1,Arg2) is side-effect free.
    reverse(Xs,_Ys)

    • If the following properties hold at call time:
      (basic_props:list/1)Xs is a list.
      then the following properties hold globally:
      (basic_props:eval/1)reverse(Xs,_Ys) is evaluable at compile-time.

    PREDICATEreverse/3

    Usage:reverse(A,B,C)

    Reverse the order of elements in A, and append it with B.

      Other properties:

      • The following properties hold globally:
        (basic_props:sideff/2)reverse(Arg1,Arg2,Arg3) is side-effect free.
      reverse(Xs,Ys,Zs)

      PREDICATEdelete/3

      Usage:delete(L1,E,L2)

      L2 is L1 without the occurrences of E.

      Other properties:

      • The following properties hold globally:
        (basic_props:sideff/2)delete(Arg1,Arg2,Arg3) is side-effect free.
      delete(L1,E,L2)

      • If the following properties hold at call time:
        (term_typing:ground/1)L1 is currently ground (it contains no variables).
        (term_typing:ground/1)L2 is currently ground (it contains no variables).
        then the following properties hold globally:
        (basic_props:eval/1)delete(L1,E,L2) is evaluable at compile-time.

      Usage:delete_non_ground(L1,E,L2)

      L2 is L1 without the occurrences of E. E can be a nonground term so that all the elements in L1 it unifies with will be deleted

      Other properties:

      • The following properties hold globally:
        (basic_props:sideff/2)delete_non_ground(Arg1,Arg2,Arg3) is side-effect true.
      delete_non_ground(L1,E,L2)

      • If the following properties hold at call time:
        (term_typing:ground/1)L1 is currently ground (it contains no variables).
        (term_typing:ground/1)L2 is currently ground (it contains no variables).
        then the following properties hold globally:
        (basic_props:eval/1)delete_non_ground(L1,E,L2) is evaluable at compile-time.

      PREDICATEselect/3

      Usage:select(X,Xs,Ys)

      Xs and Ys have the same elements except for one occurrence of X.

        Other properties:

        • The following properties hold globally:
          (basic_props:sideff/2)select(Arg1,Arg2,Arg3) is side-effect free.
        select(X,Xs,Ys)

        • If the following properties hold at call time:
          (term_typing:ground/1)X is currently ground (it contains no variables).
          (term_typing:ground/1)Xs is currently ground (it contains no variables).
          then the following properties hold globally:
          (basic_props:eval/1)select(X,Xs,Ys) is evaluable at compile-time.

        PREDICATElength/2

        Usage 1:length(L,N)

        Computes the length of L.

        Usage 2:length(L,N)

        Outputs L of length N.

        Usage 3:length(L,N)

        Checks that L is of length N.

        Other properties:
        length(A,B)

        • The following properties hold globally:
          (basic_props:native/1)This predicate is understood natively by CiaoPP.

        • The following properties hold globally:
          (basic_props:sideff/2)length(Arg1,Arg2) is side-effect free.
        length(L,N)

        • If the following properties hold at call time:
          (basic_props:list/1)L is a list.
          then the following properties hold globally:
          (basic_props:eval/1)length(L,N) is evaluable at compile-time.
        length(L,N)

        • If the following properties hold at call time:
          (term_typing:integer/1)N is currently instantiated to an integer.
          then the following properties hold globally:
          (basic_props:eval/1)length(L,N) is evaluable at compile-time.

        PREDICATEnth/3
        nth(N,List,Elem)

        N is the position in List of Elem. N counts from one.

        Usage 1:

        Unifies Elem and the Nth element of List.

        Usage 2:

        Finds the positions where Elem is in List. Positions are found in ascending order.

        Other properties:

        • The following properties hold globally:
          (basic_props:sideff/2)nth(N,List,Elem) is side-effect free.
        nth(N,L,E)

        • If the following properties hold at call time:
          (term_typing:integer/1)N is currently instantiated to an integer.
          then the following properties hold globally:
          (basic_props:eval/1)nth(N,L,E) is evaluable at compile-time.
        nth(N,L,E)

        • If the following properties hold at call time:
          (basic_props:list/1)L is a list.
          then the following properties hold globally:
          (basic_props:eval/1)nth(N,L,E) is evaluable at compile-time.
        nth(N,L,E)

        PREDICATEadd_after/4

        Usage:add_after(L0,E0,E,L)

        Adds element E after element E0 (or at end) to list L0 returning in L the new list (uses term comparison).

        PREDICATEadd_before/4

        Usage:add_before(L0,E0,E,L)

        Adds element E before element E0 (or at start) to list L0 returning in L the new list (uses term comparison).

        REGTYPElist1/2

        Usage:list1(T,X)

        X is a list of Ys of at least one element.

          Meta-predicate with arguments: list1(pred(1),?).

          PREDICATEdlist/3

          Usage:dlist(List,DList,Tail)

          List is the result of removing Tail from the end of DList (makes a difference list from a list).

            PREDICATElist_concat/2

            Usage:list_concat(LL,L)

            L is the concatenation of all the lists in LL.

            PREDICATElist_insert/2

            Usage:list_insert(List,Term)

            Adds Term to the end of List if there is no element in List identical to Term.

            • The following properties should hold at call time:
              (term_typing:nonvar/1)Term is currently a term which is not a free variable.

            PREDICATEinsert_last/3

            Usage:insert_last(L0,E,L)

            Adds element E at end of list L0 returning L.

            • The following properties should hold at call time:
              (term_typing:nonvar/1)L0 is currently a term which is not a free variable.
              (term_typing:nonvar/1)E is currently a term which is not a free variable.

            PREDICATEcontains_ro/2

            Usage:

            Impure membership (does not instantiate a variable in its first argument.

              PREDICATEcontains1/2

              Usage:

              First membership.

                PREDICATEnocontainsx/2

                Usage:nocontainsx(L,X)

                X is not identical to any element of L.

                  PREDICATElast/2

                  Usage:last(L,X)

                  X is the last element of list L.

                    PREDICATElist_lookup/3

                    Usage:list_lookup(List,Key,Value)

                    Same as list_lookup/4, but use -/2 as functor.

                      PREDICATElist_lookup/4

                      Usage:list_lookup(List,Functor,Key,Value)

                      Look up Functor(Key,Value) pair in variable ended key-value pair list L or else add it at the end.

                        Usage:intset_insert(A,B,Set)

                        Insert the element B in the ordered set of numbers A.

                          Usage:intset_delete(A,B,Set)

                          Delete from the ordered set A the element B.

                            PREDICATEintset_in/2

                            Usage:intset_in(E,Set)

                            Succeds iff E is element of Set

                              Usage:intset_sequence(N,L1,L2)

                              Generates an ordered set of numbers from 0 to N-1, and append it to L1.

                                Usage:intersection(List1,List2,List)

                                List has the elements which are both in List1 and List2.

                                PREDICATEunion/3

                                Usage:union(List1,List2,List)

                                List has the elements which are in List1 followed by the elements which are in List2 but not in List1.

                                PREDICATEdifference/3

                                Usage:difference(List1,List2,List)

                                List has the elements which are in List1 but not in List2.

                                PROPERTYsublist/2

                                Usage:sublist(List1,List2)

                                List2 contains all the elements of List1.

                                • If the following properties should hold at call time:
                                  (term_typing:nonvar/1)List2 is currently a term which is not a free variable.

                                PROPERTYsubordlist/2

                                Usage:subordlist(List1,List2)

                                List2 contains all the elements of List1 in the same order.

                                • If the following properties should hold at call time:
                                  (term_typing:nonvar/1)List2 is currently a term which is not a free variable.

                                PREDICATEequal_lists/2

                                Usage:equal_lists(List1,List2)

                                List1 has all the elements of List2, and vice versa.

                                Usage 1:list_to_list_of_lists(List,LList)

                                Usage 2:list_to_list_of_lists(List,LList)

                                LList is the list of one element lists with elements of List.

                                PREDICATEpowerset/2

                                Usage:powerset(List,LList)

                                LList is the powerset of List, i.e., the list of all lists which have elements of List. If List is ordered, LList and all its elements are ordered.

                                Usage:cross_product(LList,List)

                                List is the cartesian product of the lists in LList, that is, the list of lists formed with one element of each list in LList, in the same order.

                                Usage:sequence_to_list(Sequence,List)

                                List is the list of all elements in the (comma-separated) sequence Sequence. The use of this predicate is reversible.

                                  A regular type, defined as follows:
                                  list_of_lists([]).
                                  list_of_lists([L|Xs]) :-
                                      list(L),
                                      list_of_lists(Xs).
                                  

                                  (UNDOC_REEXPORT)member/2
                                  Imported from basic_props (see the corresponding documentation for details).

                                  (UNDOC_REEXPORT)member/2
                                  Imported from basic_props (see the corresponding documentation for details).

                                  Documentation on imports

                                  This module has the following direct dependencies: