Revert "(scm_shell_usage): Note need for subscription to bug-guile@gnu.org."
[bpt/guile.git] / libguile / vectors.c
1 /* Copyright (C) 1995,1996,1998,1999,2000,2001, 2006, 2008 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
18
19 \f
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23
24 #include "libguile/_scm.h"
25 #include "libguile/eq.h"
26 #include "libguile/root.h"
27 #include "libguile/strings.h"
28 #include "libguile/lang.h"
29
30 #include "libguile/validate.h"
31 #include "libguile/vectors.h"
32 #include "libguile/unif.h"
33 #include "libguile/ramap.h"
34 #include "libguile/srfi-4.h"
35 #include "libguile/strings.h"
36 #include "libguile/srfi-13.h"
37 #include "libguile/dynwind.h"
38 #include "libguile/deprecation.h"
39
40 \f
41
42 #define VECTOR_MAX_LENGTH (SCM_T_BITS_MAX >> 8)
43
44 int
45 scm_is_vector (SCM obj)
46 {
47 if (SCM_I_IS_VECTOR (obj))
48 return 1;
49 if (SCM_I_ARRAYP (obj) && SCM_I_ARRAY_NDIM (obj) == 1)
50 {
51 SCM v = SCM_I_ARRAY_V (obj);
52 return SCM_I_IS_VECTOR (v);
53 }
54 return 0;
55 }
56
57 int
58 scm_is_simple_vector (SCM obj)
59 {
60 return SCM_I_IS_VECTOR (obj);
61 }
62
63 const SCM *
64 scm_vector_elements (SCM vec, scm_t_array_handle *h,
65 size_t *lenp, ssize_t *incp)
66 {
67 scm_generalized_vector_get_handle (vec, h);
68 if (lenp)
69 {
70 scm_t_array_dim *dim = scm_array_handle_dims (h);
71 *lenp = dim->ubnd - dim->lbnd + 1;
72 *incp = dim->inc;
73 }
74 return scm_array_handle_elements (h);
75 }
76
77 SCM *
78 scm_vector_writable_elements (SCM vec, scm_t_array_handle *h,
79 size_t *lenp, ssize_t *incp)
80 {
81 scm_generalized_vector_get_handle (vec, h);
82 if (lenp)
83 {
84 scm_t_array_dim *dim = scm_array_handle_dims (h);
85 *lenp = dim->ubnd - dim->lbnd + 1;
86 *incp = dim->inc;
87 }
88 return scm_array_handle_writable_elements (h);
89 }
90
91 SCM_DEFINE (scm_vector_p, "vector?", 1, 0, 0,
92 (SCM obj),
93 "Return @code{#t} if @var{obj} is a vector, otherwise return\n"
94 "@code{#f}.")
95 #define FUNC_NAME s_scm_vector_p
96 {
97 return scm_from_bool (scm_is_vector (obj));
98 }
99 #undef FUNC_NAME
100
101 SCM_GPROC (s_vector_length, "vector-length", 1, 0, 0, scm_vector_length, g_vector_length);
102 /* Returns the number of elements in @var{vector} as an exact integer. */
103 SCM
104 scm_vector_length (SCM v)
105 {
106 if (SCM_I_IS_VECTOR (v))
107 return scm_from_size_t (SCM_I_VECTOR_LENGTH (v));
108 else if (SCM_I_ARRAYP (v) && SCM_I_ARRAY_NDIM (v) == 1)
109 {
110 scm_t_array_dim *dim = SCM_I_ARRAY_DIMS (v);
111 return scm_from_size_t (dim->ubnd - dim->lbnd + 1);
112 }
113 else
114 SCM_WTA_DISPATCH_1 (g_vector_length, v, 1, NULL);
115 }
116
117 size_t
118 scm_c_vector_length (SCM v)
119 {
120 if (SCM_I_IS_VECTOR (v))
121 return SCM_I_VECTOR_LENGTH (v);
122 else
123 return scm_to_size_t (scm_vector_length (v));
124 }
125
126 SCM_REGISTER_PROC (s_list_to_vector, "list->vector", 1, 0, 0, scm_vector);
127 /*
128 "Return a newly created vector initialized to the elements of"
129 "the list @var{list}.\n\n"
130 "@lisp\n"
131 "(vector->list '#(dah dah didah)) @result{} (dah dah didah)\n"
132 "(list->vector '(dididit dah)) @result{} #(dididit dah)\n"
133 "@end lisp")
134 */
135 SCM_DEFINE (scm_vector, "vector", 0, 0, 1,
136 (SCM l),
137 "@deffnx {Scheme Procedure} list->vector l\n"
138 "Return a newly allocated vector composed of the\n"
139 "given arguments. Analogous to @code{list}.\n"
140 "\n"
141 "@lisp\n"
142 "(vector 'a 'b 'c) @result{} #(a b c)\n"
143 "@end lisp")
144 #define FUNC_NAME s_scm_vector
145 {
146 SCM res;
147 SCM *data;
148 long i, len;
149 scm_t_array_handle handle;
150
151 SCM_VALIDATE_LIST_COPYLEN (1, l, len);
152
153 res = scm_c_make_vector (len, SCM_UNSPECIFIED);
154 data = scm_vector_writable_elements (res, &handle, NULL, NULL);
155 i = 0;
156 while (scm_is_pair (l) && i < len)
157 {
158 data[i] = SCM_CAR (l);
159 l = SCM_CDR (l);
160 i += 1;
161 }
162
163 scm_array_handle_release (&handle);
164
165 return res;
166 }
167 #undef FUNC_NAME
168
169 SCM_GPROC (s_vector_ref, "vector-ref", 2, 0, 0, scm_vector_ref, g_vector_ref);
170
171 /*
172 "@var{k} must be a valid index of @var{vector}.\n"
173 "@samp{Vector-ref} returns the contents of element @var{k} of\n"
174 "@var{vector}.\n\n"
175 "@lisp\n"
176 "(vector-ref '#(1 1 2 3 5 8 13 21) 5) @result{} 8\n"
177 "(vector-ref '#(1 1 2 3 5 8 13 21)\n"
178 " (let ((i (round (* 2 (acos -1)))))\n"
179 " (if (inexact? i)\n"
180 " (inexact->exact i)\n"
181 " i))) @result{} 13\n"
182 "@end lisp"
183 */
184
185 SCM
186 scm_vector_ref (SCM v, SCM k)
187 #define FUNC_NAME s_vector_ref
188 {
189 return scm_c_vector_ref (v, scm_to_size_t (k));
190 }
191 #undef FUNC_NAME
192
193 SCM
194 scm_c_vector_ref (SCM v, size_t k)
195 {
196 if (SCM_I_IS_VECTOR (v))
197 {
198 if (k >= SCM_I_VECTOR_LENGTH (v))
199 scm_out_of_range (NULL, scm_from_size_t (k));
200 return (SCM_I_VECTOR_ELTS(v))[k];
201 }
202 else if (SCM_I_ARRAYP (v) && SCM_I_ARRAY_NDIM (v) == 1)
203 {
204 scm_t_array_dim *dim = SCM_I_ARRAY_DIMS (v);
205 SCM vv = SCM_I_ARRAY_V (v);
206 if (SCM_I_IS_VECTOR (vv))
207 {
208 if (k >= dim->ubnd - dim->lbnd + 1)
209 scm_out_of_range (NULL, scm_from_size_t (k));
210 k = SCM_I_ARRAY_BASE (v) + k*dim->inc;
211 return (SCM_I_VECTOR_ELTS (vv))[k];
212 }
213 scm_wrong_type_arg_msg (NULL, 0, v, "non-uniform vector");
214 }
215 else
216 SCM_WTA_DISPATCH_2 (g_vector_ref, v, scm_from_size_t (k), 2, NULL);
217 }
218
219 SCM_GPROC (s_vector_set_x, "vector-set!", 3, 0, 0, scm_vector_set_x, g_vector_set_x);
220
221 /* "@var{k} must be a valid index of @var{vector}.\n"
222 "@code{Vector-set!} stores @var{obj} in element @var{k} of @var{vector}.\n"
223 "The value returned by @samp{vector-set!} is unspecified.\n"
224 "@lisp\n"
225 "(let ((vec (vector 0 '(2 2 2 2) "Anna")))\n"
226 " (vector-set! vec 1 '("Sue" "Sue"))\n"
227 " vec) @result{} #(0 ("Sue" "Sue") "Anna")\n"
228 "(vector-set! '#(0 1 2) 1 "doe") @result{} @emph{error} ; constant vector\n"
229 "@end lisp"
230 */
231
232 SCM
233 scm_vector_set_x (SCM v, SCM k, SCM obj)
234 #define FUNC_NAME s_vector_set_x
235 {
236 scm_c_vector_set_x (v, scm_to_size_t (k), obj);
237 return SCM_UNSPECIFIED;
238 }
239 #undef FUNC_NAME
240
241 void
242 scm_c_vector_set_x (SCM v, size_t k, SCM obj)
243 {
244 if (SCM_I_IS_VECTOR (v))
245 {
246 if (k >= SCM_I_VECTOR_LENGTH (v))
247 scm_out_of_range (NULL, scm_from_size_t (k));
248 (SCM_I_VECTOR_WELTS(v))[k] = obj;
249 }
250 else if (SCM_I_ARRAYP (v) && SCM_I_ARRAY_NDIM (v) == 1)
251 {
252 scm_t_array_dim *dim = SCM_I_ARRAY_DIMS (v);
253 SCM vv = SCM_I_ARRAY_V (v);
254 if (SCM_I_IS_VECTOR (vv))
255 {
256 if (k >= dim->ubnd - dim->lbnd + 1)
257 scm_out_of_range (NULL, scm_from_size_t (k));
258 k = SCM_I_ARRAY_BASE (v) + k*dim->inc;
259 (SCM_I_VECTOR_WELTS (vv))[k] = obj;
260 }
261 else
262 scm_wrong_type_arg_msg (NULL, 0, v, "non-uniform vector");
263 }
264 else
265 {
266 if (SCM_UNPACK (g_vector_set_x))
267 scm_apply_generic (g_vector_set_x,
268 scm_list_3 (v, scm_from_size_t (k), obj));
269 else
270 scm_wrong_type_arg_msg (NULL, 0, v, "vector");
271 }
272 }
273
274 SCM_DEFINE (scm_make_vector, "make-vector", 1, 1, 0,
275 (SCM k, SCM fill),
276 "Return a newly allocated vector of @var{k} elements. If a\n"
277 "second argument is given, then each position is initialized to\n"
278 "@var{fill}. Otherwise the initial contents of each position is\n"
279 "unspecified.")
280 #define FUNC_NAME s_scm_make_vector
281 {
282 size_t l = scm_to_unsigned_integer (k, 0, VECTOR_MAX_LENGTH);
283
284 if (SCM_UNBNDP (fill))
285 fill = SCM_UNSPECIFIED;
286
287 return scm_c_make_vector (l, fill);
288 }
289 #undef FUNC_NAME
290
291
292 SCM
293 scm_c_make_vector (size_t k, SCM fill)
294 #define FUNC_NAME s_scm_make_vector
295 {
296 SCM v;
297 SCM *base;
298
299 if (k > 0)
300 {
301 unsigned long int j;
302
303 SCM_ASSERT_RANGE (1, scm_from_ulong (k), k <= VECTOR_MAX_LENGTH);
304
305 base = scm_gc_malloc (k * sizeof (SCM), "vector");
306 for (j = 0; j != k; ++j)
307 base[j] = fill;
308 }
309 else
310 base = NULL;
311
312 v = scm_cell ((k << 8) | scm_tc7_vector, (scm_t_bits) base);
313 scm_remember_upto_here_1 (fill);
314
315 return v;
316 }
317 #undef FUNC_NAME
318
319 SCM_DEFINE (scm_vector_copy, "vector-copy", 1, 0, 0,
320 (SCM vec),
321 "Return a copy of @var{vec}.")
322 #define FUNC_NAME s_scm_vector_copy
323 {
324 scm_t_array_handle handle;
325 size_t i, len;
326 ssize_t inc;
327 const SCM *src;
328 SCM *dst;
329
330 src = scm_vector_elements (vec, &handle, &len, &inc);
331 dst = scm_gc_malloc (len * sizeof (SCM), "vector");
332 for (i = 0; i < len; i++, src += inc)
333 dst[i] = *src;
334 scm_array_handle_release (&handle);
335
336 return scm_cell ((len << 8) | scm_tc7_vector, (scm_t_bits) dst);
337 }
338 #undef FUNC_NAME
339
340 void
341 scm_i_vector_free (SCM vec)
342 {
343 scm_gc_free (SCM_I_VECTOR_WELTS (vec),
344 SCM_I_VECTOR_LENGTH (vec) * sizeof(SCM),
345 "vector");
346 }
347
348 /* Allocate memory for a weak vector on behalf of the caller. The allocated
349 * vector will be of the given weak vector subtype. It will contain size
350 * elements which are initialized with the 'fill' object, or, if 'fill' is
351 * undefined, with an unspecified object.
352 */
353 SCM
354 scm_i_allocate_weak_vector (scm_t_bits type, SCM size, SCM fill)
355 {
356 size_t c_size;
357 SCM *base;
358 SCM v;
359
360 c_size = scm_to_unsigned_integer (size, 0, VECTOR_MAX_LENGTH);
361
362 if (c_size > 0)
363 {
364 size_t j;
365
366 if (SCM_UNBNDP (fill))
367 fill = SCM_UNSPECIFIED;
368
369 base = scm_gc_malloc (c_size * sizeof (SCM), "weak vector");
370 for (j = 0; j != c_size; ++j)
371 base[j] = fill;
372 }
373 else
374 base = NULL;
375
376 v = scm_double_cell ((c_size << 8) | scm_tc7_wvect,
377 (scm_t_bits) base,
378 type,
379 SCM_UNPACK (SCM_EOL));
380 scm_remember_upto_here_1 (fill);
381
382 return v;
383 }
384
385 SCM_DEFINE (scm_vector_to_list, "vector->list", 1, 0, 0,
386 (SCM v),
387 "Return a newly allocated list composed of the elements of @var{v}.\n"
388 "\n"
389 "@lisp\n"
390 "(vector->list '#(dah dah didah)) @result{} (dah dah didah)\n"
391 "(list->vector '(dididit dah)) @result{} #(dididit dah)\n"
392 "@end lisp")
393 #define FUNC_NAME s_scm_vector_to_list
394 {
395 SCM res = SCM_EOL;
396 const SCM *data;
397 scm_t_array_handle handle;
398 size_t i, count, len;
399 ssize_t inc;
400
401 data = scm_vector_elements (v, &handle, &len, &inc);
402 for (i = (len - 1) * inc, count = 0;
403 count < len;
404 i -= inc, count++)
405 res = scm_cons (data[i], res);
406
407 scm_array_handle_release (&handle);
408 return res;
409 }
410 #undef FUNC_NAME
411
412
413 SCM_DEFINE (scm_vector_fill_x, "vector-fill!", 2, 0, 0,
414 (SCM v, SCM fill),
415 "Store @var{fill} in every position of @var{vector}. The value\n"
416 "returned by @code{vector-fill!} is unspecified.")
417 #define FUNC_NAME s_scm_vector_fill_x
418 {
419 scm_t_array_handle handle;
420 SCM *data;
421 size_t i, len;
422 ssize_t inc;
423
424 data = scm_vector_writable_elements (v, &handle, &len, &inc);
425 for (i = 0; i < len; i += inc)
426 data[i] = fill;
427 scm_array_handle_release (&handle);
428 return SCM_UNSPECIFIED;
429 }
430 #undef FUNC_NAME
431
432
433 SCM
434 scm_i_vector_equal_p (SCM x, SCM y)
435 {
436 long i;
437 for (i = SCM_I_VECTOR_LENGTH (x) - 1; i >= 0; i--)
438 if (scm_is_false (scm_equal_p (SCM_I_VECTOR_ELTS (x)[i],
439 SCM_I_VECTOR_ELTS (y)[i])))
440 return SCM_BOOL_F;
441 return SCM_BOOL_T;
442 }
443
444
445 SCM_DEFINE (scm_vector_move_left_x, "vector-move-left!", 5, 0, 0,
446 (SCM vec1, SCM start1, SCM end1, SCM vec2, SCM start2),
447 "Copy elements from @var{vec1}, positions @var{start1} to @var{end1},\n"
448 "to @var{vec2} starting at position @var{start2}. @var{start1} and\n"
449 "@var{start2} are inclusive indices; @var{end1} is exclusive.\n\n"
450 "@code{vector-move-left!} copies elements in leftmost order.\n"
451 "Therefore, in the case where @var{vec1} and @var{vec2} refer to the\n"
452 "same vector, @code{vector-move-left!} is usually appropriate when\n"
453 "@var{start1} is greater than @var{start2}.")
454 #define FUNC_NAME s_scm_vector_move_left_x
455 {
456 scm_t_array_handle handle1, handle2;
457 const SCM *elts1;
458 SCM *elts2;
459 size_t len1, len2;
460 ssize_t inc1, inc2;
461 size_t i, j, e;
462
463 elts1 = scm_vector_elements (vec1, &handle1, &len1, &inc1);
464 elts2 = scm_vector_writable_elements (vec2, &handle2, &len2, &inc2);
465
466 i = scm_to_unsigned_integer (start1, 0, len1);
467 e = scm_to_unsigned_integer (end1, i, len1);
468 j = scm_to_unsigned_integer (start2, 0, len2 - (i-e));
469
470 i *= inc1;
471 e *= inc1;
472 j *= inc2;
473 for (; i < e; i += inc1, j += inc2)
474 elts2[j] = elts1[i];
475
476 scm_array_handle_release (&handle2);
477 scm_array_handle_release (&handle1);
478
479 return SCM_UNSPECIFIED;
480 }
481 #undef FUNC_NAME
482
483 SCM_DEFINE (scm_vector_move_right_x, "vector-move-right!", 5, 0, 0,
484 (SCM vec1, SCM start1, SCM end1, SCM vec2, SCM start2),
485 "Copy elements from @var{vec1}, positions @var{start1} to @var{end1},\n"
486 "to @var{vec2} starting at position @var{start2}. @var{start1} and\n"
487 "@var{start2} are inclusive indices; @var{end1} is exclusive.\n\n"
488 "@code{vector-move-right!} copies elements in rightmost order.\n"
489 "Therefore, in the case where @var{vec1} and @var{vec2} refer to the\n"
490 "same vector, @code{vector-move-right!} is usually appropriate when\n"
491 "@var{start1} is less than @var{start2}.")
492 #define FUNC_NAME s_scm_vector_move_right_x
493 {
494 scm_t_array_handle handle1, handle2;
495 const SCM *elts1;
496 SCM *elts2;
497 size_t len1, len2;
498 ssize_t inc1, inc2;
499 size_t i, j, e;
500
501 elts1 = scm_vector_elements (vec1, &handle1, &len1, &inc1);
502 elts2 = scm_vector_writable_elements (vec2, &handle2, &len2, &inc2);
503
504 i = scm_to_unsigned_integer (start1, 0, len1);
505 e = scm_to_unsigned_integer (end1, i, len1);
506 j = scm_to_unsigned_integer (start2, 0, len2 - (i-e));
507
508 i *= inc1;
509 e *= inc1;
510 j *= inc2;
511 while (i < e)
512 {
513 e -= inc1;
514 j -= inc2;
515 elts2[j] = elts1[e];
516 }
517
518 scm_array_handle_release (&handle2);
519 scm_array_handle_release (&handle1);
520
521 return SCM_UNSPECIFIED;
522 }
523 #undef FUNC_NAME
524
525
526 /* Generalized vectors. */
527
528 int
529 scm_is_generalized_vector (SCM obj)
530 {
531 return (scm_is_vector (obj)
532 || scm_is_string (obj)
533 || scm_is_bitvector (obj)
534 || scm_is_uniform_vector (obj));
535 }
536
537 SCM_DEFINE (scm_generalized_vector_p, "generalized-vector?", 1, 0, 0,
538 (SCM obj),
539 "Return @code{#t} if @var{obj} is a vector, string,\n"
540 "bitvector, or uniform numeric vector.")
541 #define FUNC_NAME s_scm_generalized_vector_p
542 {
543 return scm_from_bool (scm_is_generalized_vector (obj));
544 }
545 #undef FUNC_NAME
546
547 void
548 scm_generalized_vector_get_handle (SCM vec, scm_t_array_handle *h)
549 {
550 scm_array_get_handle (vec, h);
551 if (scm_array_handle_rank (h) != 1)
552 scm_wrong_type_arg_msg (NULL, 0, vec, "vector");
553 }
554
555 size_t
556 scm_c_generalized_vector_length (SCM v)
557 {
558 if (scm_is_vector (v))
559 return scm_c_vector_length (v);
560 else if (scm_is_string (v))
561 return scm_c_string_length (v);
562 else if (scm_is_bitvector (v))
563 return scm_c_bitvector_length (v);
564 else if (scm_is_uniform_vector (v))
565 return scm_c_uniform_vector_length (v);
566 else
567 scm_wrong_type_arg_msg (NULL, 0, v, "generalized vector");
568 }
569
570 SCM_DEFINE (scm_generalized_vector_length, "generalized-vector-length", 1, 0, 0,
571 (SCM v),
572 "Return the length of the generalized vector @var{v}.")
573 #define FUNC_NAME s_scm_generalized_vector_length
574 {
575 return scm_from_size_t (scm_c_generalized_vector_length (v));
576 }
577 #undef FUNC_NAME
578
579 SCM
580 scm_c_generalized_vector_ref (SCM v, size_t idx)
581 {
582 if (scm_is_vector (v))
583 return scm_c_vector_ref (v, idx);
584 else if (scm_is_string (v))
585 return scm_c_string_ref (v, idx);
586 else if (scm_is_bitvector (v))
587 return scm_c_bitvector_ref (v, idx);
588 else if (scm_is_uniform_vector (v))
589 return scm_c_uniform_vector_ref (v, idx);
590 else
591 scm_wrong_type_arg_msg (NULL, 0, v, "generalized vector");
592 }
593
594 SCM_DEFINE (scm_generalized_vector_ref, "generalized-vector-ref", 2, 0, 0,
595 (SCM v, SCM idx),
596 "Return the element at index @var{idx} of the\n"
597 "generalized vector @var{v}.")
598 #define FUNC_NAME s_scm_generalized_vector_ref
599 {
600 return scm_c_generalized_vector_ref (v, scm_to_size_t (idx));
601 }
602 #undef FUNC_NAME
603
604 void
605 scm_c_generalized_vector_set_x (SCM v, size_t idx, SCM val)
606 {
607 if (scm_is_vector (v))
608 scm_c_vector_set_x (v, idx, val);
609 else if (scm_is_string (v))
610 scm_c_string_set_x (v, idx, val);
611 else if (scm_is_bitvector (v))
612 scm_c_bitvector_set_x (v, idx, val);
613 else if (scm_is_uniform_vector (v))
614 scm_c_uniform_vector_set_x (v, idx, val);
615 else
616 scm_wrong_type_arg_msg (NULL, 0, v, "generalized vector");
617 }
618
619 SCM_DEFINE (scm_generalized_vector_set_x, "generalized-vector-set!", 3, 0, 0,
620 (SCM v, SCM idx, SCM val),
621 "Set the element at index @var{idx} of the\n"
622 "generalized vector @var{v} to @var{val}.")
623 #define FUNC_NAME s_scm_generalized_vector_set_x
624 {
625 scm_c_generalized_vector_set_x (v, scm_to_size_t (idx), val);
626 return SCM_UNSPECIFIED;
627 }
628 #undef FUNC_NAME
629
630 SCM_DEFINE (scm_generalized_vector_to_list, "generalized-vector->list", 1, 0, 0,
631 (SCM v),
632 "Return a new list whose elements are the elements of the\n"
633 "generalized vector @var{v}.")
634 #define FUNC_NAME s_scm_generalized_vector_to_list
635 {
636 if (scm_is_vector (v))
637 return scm_vector_to_list (v);
638 else if (scm_is_string (v))
639 return scm_string_to_list (v);
640 else if (scm_is_bitvector (v))
641 return scm_bitvector_to_list (v);
642 else if (scm_is_uniform_vector (v))
643 return scm_uniform_vector_to_list (v);
644 else
645 scm_wrong_type_arg_msg (NULL, 0, v, "generalized vector");
646 }
647 #undef FUNC_NAME
648
649
650 void
651 scm_init_vectors ()
652 {
653 scm_nullvect = scm_c_make_vector (0, SCM_UNDEFINED);
654
655 #include "libguile/vectors.x"
656 }
657
658
659 /*
660 Local Variables:
661 c-file-style: "gnu"
662 End:
663 */