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