Commit | Line | Data |
---|---|---|
58ade102 | 1 | /* Copyright (C) 1995,1996,1997, 2000, 2001 Free Software Foundation, Inc. |
ee2a8b9b | 2 | |
73be1d9e MV |
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. | |
ee2a8b9b | 7 | * |
73be1d9e MV |
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. | |
ee2a8b9b | 12 | * |
73be1d9e MV |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
16 | */ | |
ee2a8b9b JB |
17 | \f |
18 | ||
19 | /* list manipulation */ | |
20 | ||
a0599745 | 21 | #include "libguile/gh.h" |
ee2a8b9b JB |
22 | |
23 | /* returns the length of a list */ | |
c014a02e | 24 | unsigned long |
92396c0a | 25 | gh_length (SCM l) |
ee2a8b9b | 26 | { |
92396c0a | 27 | return gh_scm2ulong (scm_length (l)); |
ee2a8b9b JB |
28 | } |
29 | ||
30 | /* list operations */ | |
31 | ||
7fee59bd MG |
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 ...) */ | |
1be6b49c | 37 | SCM |
1afff620 | 38 | gh_append (SCM args) |
7fee59bd | 39 | { |
1afff620 | 40 | return scm_append (args); |
7fee59bd MG |
41 | } |
42 | ||
1be6b49c | 43 | SCM |
1afff620 | 44 | gh_append2 (SCM l1, SCM l2) |
7fee59bd | 45 | { |
1afff620 | 46 | return scm_append (scm_list_2 (l1, l2)); |
7fee59bd MG |
47 | } |
48 | ||
1be6b49c ML |
49 | SCM |
50 | gh_append3(SCM l1, SCM l2, SCM l3) | |
7fee59bd | 51 | { |
1afff620 | 52 | return scm_append (scm_list_3 (l1, l2, l3)); |
7fee59bd MG |
53 | } |
54 | ||
1be6b49c | 55 | SCM |
1afff620 | 56 | gh_append4 (SCM l1, SCM l2, SCM l3, SCM l4) |
7fee59bd | 57 | { |
1afff620 | 58 | return scm_append (scm_list_4 (l1, l2, l3, l4)); |
7fee59bd MG |
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 | ||
ee2a8b9b JB |
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 | ||
ee2a8b9b JB |
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 | } | |
7fee59bd MG |
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 | } | |
89e00824 ML |
168 | |
169 | /* | |
170 | Local Variables: | |
171 | c-file-style: "gnu" | |
172 | End: | |
173 | */ |