The FSF has a new address.
[bpt/guile.git] / libguile / gh_list.c
1 /* Copyright (C) 1995,1996,1997, 2000, 2001, 2004 Free Software Foundation, Inc.
2
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 \f
18
19 /* list manipulation */
20
21 #include "libguile/gh.h"
22
23 /* returns the length of a list */
24 unsigned long
25 gh_length (SCM l)
26 {
27 return gh_scm2ulong (scm_length (l));
28 }
29
30 /* list operations */
31
32 /* gh_list(SCM elt, ...) is implemented as a macro in gh.h. */
33
34 /* gh_append() takes a args, which is a list of lists, and appends
35 them all together into a single list, which is returned. This is
36 equivalent to the Scheme procedure (append list1 list2 ...) */
37 SCM
38 gh_append (SCM args)
39 {
40 return scm_append (args);
41 }
42
43 SCM
44 gh_append2 (SCM l1, SCM l2)
45 {
46 return scm_append (scm_list_2 (l1, l2));
47 }
48
49 SCM
50 gh_append3(SCM l1, SCM l2, SCM l3)
51 {
52 return scm_append (scm_list_3 (l1, l2, l3));
53 }
54
55 SCM
56 gh_append4 (SCM l1, SCM l2, SCM l3, SCM l4)
57 {
58 return scm_append (scm_list_4 (l1, l2, l3, l4));
59 }
60
61 /* gh_reverse() is defined as a macro in gh.h */
62 /* gh_list_tail() is defined as a macro in gh.h */
63 /* gh_list_ref() is defined as a macro in gh.h */
64 /* gh_memq() is defined as a macro in gh.h */
65 /* gh_memv() is defined as a macro in gh.h */
66 /* gh_member() is defined as a macro in gh.h */
67 /* gh_assq() is defined as a macro in gh.h */
68 /* gh_assv() is defined as a macro in gh.h */
69 /* gh_assoc() is defined as a macro in gh.h */
70
71 /* analogous to the Scheme cons operator */
72 SCM
73 gh_cons (SCM x, SCM y)
74 {
75 return scm_cons (x, y);
76 }
77
78 /* analogous to the Scheme car operator */
79 SCM
80 gh_car (SCM x)
81 {
82 return scm_car (x);
83 }
84
85 /* analogous to the Scheme cdr operator */
86 SCM
87 gh_cdr (SCM x)
88 {
89 return scm_cdr (x);
90 }
91
92 /* now for the multiple car/cdr utility procedures */
93 SCM
94 gh_caar (SCM x)
95 {
96 return scm_caar (x);
97 }
98 SCM
99 gh_cadr (SCM x)
100 {
101 return scm_cadr (x);
102 }
103 SCM
104 gh_cdar (SCM x)
105 {
106 return scm_cdar (x);
107 }
108 SCM
109 gh_cddr (SCM x)
110 {
111 return scm_cddr (x);
112 }
113
114 SCM
115 gh_caaar (SCM x)
116 {
117 return scm_caaar (x);
118 }
119 SCM
120 gh_caadr (SCM x)
121 {
122 return scm_caadr (x);
123 }
124 SCM
125 gh_cadar (SCM x)
126 {
127 return scm_cadar (x);
128 }
129 SCM
130 gh_caddr (SCM x)
131 {
132 return scm_caddr (x);
133 }
134 SCM
135 gh_cdaar (SCM x)
136 {
137 return scm_cdaar (x);
138 }
139 SCM
140 gh_cdadr (SCM x)
141 {
142 return scm_cdadr (x);
143 }
144 SCM
145 gh_cddar (SCM x)
146 {
147 return scm_cddar (x);
148 }
149 SCM
150 gh_cdddr (SCM x)
151 {
152 return scm_cdddr (x);
153 }
154
155 /* equivalent to (set-car! pair value) */
156 SCM
157 gh_set_car_x(SCM pair, SCM value)
158 {
159 return scm_set_car_x(pair, value);
160 }
161
162 /* equivalent to (set-cdr! pair value) */
163 SCM
164 gh_set_cdr_x(SCM pair, SCM value)
165 {
166 return scm_set_cdr_x(pair, value);
167 }
168
169 /*
170 Local Variables:
171 c-file-style: "gnu"
172 End:
173 */