1 /* Copyright (C) 1995,1996,1997, 2000, 2001, 2004 Free Software Foundation, Inc.
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.
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.
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
19 /* list manipulation */
21 #include "libguile/gh.h"
23 /* returns the length of a list */
27 return gh_scm2ulong (scm_length (l
));
32 /* gh_list(SCM elt, ...) is implemented as a macro in gh.h. */
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 ...) */
40 return scm_append (args
);
44 gh_append2 (SCM l1
, SCM l2
)
46 return scm_append (scm_list_2 (l1
, l2
));
50 gh_append3(SCM l1
, SCM l2
, SCM l3
)
52 return scm_append (scm_list_3 (l1
, l2
, l3
));
56 gh_append4 (SCM l1
, SCM l2
, SCM l3
, SCM l4
)
58 return scm_append (scm_list_4 (l1
, l2
, l3
, l4
));
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 */
71 /* analogous to the Scheme cons operator */
73 gh_cons (SCM x
, SCM y
)
75 return scm_cons (x
, y
);
78 /* analogous to the Scheme car operator */
85 /* analogous to the Scheme cdr operator */
92 /* now for the multiple car/cdr utility procedures */
117 return scm_caaar (x
);
122 return scm_caadr (x
);
127 return scm_cadar (x
);
132 return scm_caddr (x
);
137 return scm_cdaar (x
);
142 return scm_cdadr (x
);
147 return scm_cddar (x
);
152 return scm_cdddr (x
);
155 /* equivalent to (set-car! pair value) */
157 gh_set_car_x(SCM pair
, SCM value
)
159 return scm_set_car_x(pair
, value
);
162 /* equivalent to (set-cdr! pair value) */
164 gh_set_cdr_x(SCM pair
, SCM value
)
166 return scm_set_cdr_x(pair
, value
);