You are looking at historical revision 20221 of this page. It may differ significantly from its current revision.

## srfi-4-utils

Utility functions for SRFI-4 vectors.

## Usage

(require-extension srfi-4-utils)

## Documentation

`srfi-4-utils` contains a set of convenience procedures for SRFI-4 vectors: `fold`, `map`, `quick-sort!`.

### Procedures

For each value of `TAG` in `{ s8, u8, s16, u16, s32, u32, f32, f64 `}, the following procedures are defined:

*[procedure]*

`TAGvector-fold :: F * X0 * V [* V1 ... VN] -> XN`

where `F :: V(I) [ * V1(I) ... VN(I)] * AX -> AX`

*[procedure]*

`TAGvector-map :: F * V [ * V1 ... VN] -> V`

*[procedure]*

`TAGvector-foldi :: F * X0 * V [ * V1 ... VN] -> XN`

where `F :: I * V(I) [ * V1(I) ... VN(I)] * AX -> AX`

*[procedure]*

`TAGvector-mapi :: F * V [* V1 ... VN] -> V`

where `F :: I * V(I) [* V1(I) ... VN(I)] -> V`

*[procedure]*

`TAGvector-quick-sort! :: V * ELT< [ * START * END] -> V`

where `F :: i1 * V(i1) * i2 * V(i2) -> boolean`

## Examples

csi> (f64vector-map (lambda (v) (* 2 v)) (f64vector 1 2 3)) -> #f64(2.0 4.0 6.0) csi> (f64vector-fold (lambda (v ax) (+ v ax)) (f64vector 1 2 3) 0) -> 6.0 ;; input vector is modified csi> (f64vector-quick-sort! (f64vector 1 4 2 3) (lambda (i1 v1 i2 v2) (< v1 v2))) #f64(1.0 2.0 3.0 4.0)

## About this egg

### Author

### Version history

- 1.6
- Documentation converted to wiki format
- 1.5
- Ported to Chicken 4
- 1.4
- Build script bug fix
- 1.3
- Build script updated for better cross-platform compatibility
- 1.2
- Extended fold and map interface to support multiple vector arguments
- 1.1
- Added foldi and mapi procedures
- 1.0
- Initial release

### License

Copyright 2007-2010 Ivan Raikov and the Okinawa Institute of Science and Technology This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A full copy of the GPL license can be found at <http://www.gnu.org/licenses/>.