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

9.3 gauche.collection - Collection framework

Module: gauche.collection
This module provides a set of generic functions (GFs) that iterate over various collections. The Scheme standard [R5RS] has some iterative primitives such as map and for-each, and SRFI-1 (See section 10.2 srfi-1 - List library adds a rich set of such functions, but they work only on lists.

Using the method dispatch of the object system, this module efficiently extends those functions for other collection classes such as vectors and hash tables. It also provides a simple way for user-defined class to adapt those opertaions. So far, the following operations are defined.

Mapping
fold, map, map-to, for-each
Selection and searching
find, filter, filter-to, remove, remove-to, partition, partition-to
Conversion
coerce-to
Miscellaneous
size-of, lazy-size-of
Fundamental iterator creator
call-with-iterator, call-with-builder, with-iterator, with-builder, call-with-iterators.

Those operations work on collections and its subclass, sequences. A collection is a certain form of a set of objects that you can traverse all the object in it in a certain way. A sequence is a collection that all its elements are ordered, so that you can retrieve its element by index.

The following Gauche built-in objects are treated as collections and/or sequences.

<list>
A sequence.
<vector>
A sequence.
<string>
A sequence (of characters)
<hash-table>
A collection. Each element is a pair of a key and a value.
<s8vector>, <u8vector>, ... <f64vector>
A sequence (methods defined in srfi-4 module, See section 10.4 srfi-4 - Homogeneous vectors).

See section 9.18 gauche.sequence - Sequence framework, for it adds more sequence specific methods.

The methods that needs to return a set of objects, i.e. map, filter, remove and partition. returns a list (or lists). The corresponding "-to" variant (map-to, filter-to, remove-to and partition-to. takes a collection class argument and returns the collection of the class.

9.3.1 Mapping over collection  
9.3.2 Selection and searching in collection  
9.3.3 Miscellaneous operations on collection  
9.3.4 Fundamental iterator creators  
9.3.5 Implementing collections  


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

This document was generated by Ken Dickey on November, 28 2002 using texi2html