chickadee » srfi-4-utils

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!, merge!, merge-sort!.

Procedures

s8vector-foldprocedure
u8vector-foldprocedure
s16vector-foldprocedure
u16vector-foldprocedure
s32vector-foldprocedure
u32vector-foldprocedure
f32vector-foldprocedure
f64vector-foldprocedure

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

s8vector-mapprocedure
u8vector-mapprocedure
s16vector-mapprocedure
u16vector-mapprocedure
s32vector-mapprocedure
u32vector-mapprocedure
f32vector-mapprocedure
f64vector-mapprocedure
s8vector-foldiprocedure
u8vector-foldiprocedure
s16vector-foldiprocedure
u16vector-foldiprocedure
s32vector-foldiprocedure
u32vector-foldiprocedure
f32vector-foldiprocedure
f64vector-foldiprocedure

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

s8vector-mapiprocedure
u8vector-mapiprocedure
s16vector-mapiprocedure
u16vector-mapiprocedure
s32vector-mapiprocedure
u32vector-mapiprocedure
f32ector-mapiprocedure
f64vector-mapiprocedure

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

s8vector-blit!procedure
u8vector-blit!procedure
s16vector-blit!procedure
u16vector-blit!procedure
s32vector-blit!procedure
u32vector-blit!procedure
f32vector-blit!procedure
f64vector-blit!procedure

Copies subvector VFROM[I,END) into VTO[J,J+(END-I)).

s8vector-merge!procedure
u8vector-merge!procedure
s16vector-merge!procedure
u16vector-merge!procedure
s32vector-merge!procedure
u32vector-merge!procedure
f32vector-merge!procedure
f64vector-merge!procedure

Given vector VA and indices P, Q, R such that P < Q < R, merges subvector VA[P,Q) and subvector A[Q,R) into vector B[N,N+(R-P)). The comparison function ELT< must be of type ELT< :: i1 * V(i1) * i2 * V(i2) -> boolean.

s8vector-quick-sort!procedure
u8vector-quick-sort!procedure
s16vector-quick-sort!procedure
u16vector-quick-sort!procedure
s32vector-quick-sort!procedure
u32vector-quick-sort!procedure
f32vector-quick-sort!procedure
f64vector-quick-sort!procedure

where ELT< :: i1 * V(i1) * i2 * V(i2) -> boolean

s8vector-merge-sort!procedure
u8vector-merge-sort!procedure
s16vector-merge-sort!procedure
u16vector-merge-sort!procedure
s32vector-merge-sort!procedure
u32vector-merge-sort!procedure
f32vector-merge-sort!procedure
f64vector-merge-sort!procedure

where ELT< :: 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! (lambda (i1 v1 i2 v2) (< v1 v2)) (f64vector 1 4 2 3) )
#f64(1.0 2.0 3.0 4.0)

About this egg

Author

Ivan Raikov

Version history

1.9
Added merge! and merge-sort! procedures
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-2013 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/>.

Contents »