manpagez: man pages & more
info guile
Home | html | info | man
 [ << ] [ < ] [ Up ] [ > ] [ >> ] [Top] [Contents] [Index] [ ? ]

### 6.7.5 Generalized Vectors

Guile has a number of data types that are generally vector-like: strings, uniform numeric vectors, bytevectors, bitvectors, and of course ordinary vectors of arbitrary Scheme values. These types are disjoint: a Scheme value belongs to at most one of the five types listed above.

If you want to gloss over this distinction and want to treat all four types with common code, you can use the procedures in this section. They work with the generalized vector type, which is the union of the five vector-like types.

Scheme Procedure: generalized-vector? obj
C Function: scm_generalized_vector_p (obj)

Return `#t` if obj is a vector, bytevector, string, bitvector, or uniform numeric vector.

Scheme Procedure: generalized-vector-length v
C Function: scm_generalized_vector_length (v)

Return the length of the generalized vector v.

Scheme Procedure: generalized-vector-ref v idx
C Function: scm_generalized_vector_ref (v, idx)

Return the element at index idx of the generalized vector v.

Scheme Procedure: generalized-vector-set! v idx val
C Function: scm_generalized_vector_set_x (v, idx, val)

Set the element at index idx of the generalized vector v to val.

Scheme Procedure: generalized-vector->list v
C Function: scm_generalized_vector_to_list (v)

Return a new list whose elements are the elements of the generalized vector v.

C Function: int scm_is_generalized_vector (SCM obj)

Return `1` if obj is a vector, string, bitvector, or uniform numeric vector; else return `0`.

C Function: size_t scm_c_generalized_vector_length (SCM v)

Return the length of the generalized vector v.

C Function: SCM scm_c_generalized_vector_ref (SCM v, size_t idx)

Return the element at index idx of the generalized vector v.

C Function: void scm_c_generalized_vector_set_x (SCM v, size_t idx, SCM val)

Set the element at index idx of the generalized vector v to val.

C Function: void scm_generalized_vector_get_handle (SCM v, scm_t_array_handle *handle)

Like `scm_array_get_handle` but an error is signalled when v is not of rank one. You can use `scm_array_handle_ref` and `scm_array_handle_set` to read and write the elements of v, or you can use functions like `scm_array_handle_<foo>_elements` to deal with specific types of vectors.

 [ << ] [ < ] [ Up ] [ > ] [ >> ] [Top] [Contents] [Index] [ ? ]

This document was generated on February 3, 2012 using texi2html 5.0.

```© manpagez.com 2000-2018