2 Simple imperative list buffer utility (used for instruction buffers)
3 Copyright (C) 2002,2001 Justin David Smith, Caltech
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation,
8 version 2.1 of the License.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 Additional permission is given to link this library with the
20 OpenSSL project's "OpenSSL" library, and with the OCaml runtime,
21 and you may distribute the linked executables. See the file
22 LICENSE.libmojave for more details.
26 (*** Type definitions ***)
38 let of_elt elt
= RevList
[elt
]
40 let of_list ls
= FwdList ls
56 RevList
(elt
:: List.rev buf
)
61 let rec add_list buf
= function
63 add_list (elt
:: buf
) ls
71 add_list (List.rev buf
) ls
75 let add_rev_list buf ls
=
76 let rec add_rev_list buf
= function
78 elt
:: (add_rev_list buf ls
)
86 RevList
(add_rev_list (List.rev buf
) ls
)
88 RevList
(add_rev_list buf ls
)
90 let add_listbuf buf ls
=
91 let rec add_listbuf_rev buf
= function
93 elt
:: (add_listbuf_rev buf ls
)
97 let add_listbuf_rev buf ls
= RevList
(add_listbuf_rev buf ls
) in
105 | FwdList buf
, RevList ls
->
106 add_listbuf_rev (List.rev buf
) ls
107 | RevList buf
, RevList ls
->
108 add_listbuf_rev buf ls