source: project/wiki/eggref/4/srfi-4-utils @ 20221

Last change on this file since 20221 was 20221, checked in by Ivan Raikov, 11 years ago

srfi-4-utils wiki doc

File size: 2.3 KB
Line 
1[[tags:egg]]
2
3== srfi-4-utils
4
5Utility functions for SRFI-4 vectors.
6
7[[toc:]]
8
9== Usage
10
11(require-extension srfi-4-utils)
12
13== Documentation
14
15{{srfi-4-utils}} contains a set of convenience procedures for
16[[http://srfi.schemers.org/srfi-4/srfi-4.html|SRFI-4]] vectors:
17{{fold}}, {{map}}, {{quick-sort!}}.
18
19=== Procedures
20
21
22For each value of {{TAG}} in {{{ s8, u8, s16, u16, s32, u32, f32, f64
23}}}, the following procedures are defined:
24
25<procedure>TAGvector-fold :: F * X0 * V [* V1 ... VN] -> XN</procedure>
26
27where {{F :: V(I) [ * V1(I) ... VN(I)] * AX -> AX}}
28
29<procedure>TAGvector-map :: F * V [ * V1 ... VN] -> V</procedure>
30
31<procedure>TAGvector-foldi :: F * X0 * V [ * V1 ... VN] -> XN</procedure>
32
33where {{F :: I * V(I) [ * V1(I) ... VN(I)] * AX -> AX}}
34
35<procedure>TAGvector-mapi :: F * V [* V1 ... VN] -> V</procedure>
36
37where {{F :: I * V(I) [* V1(I) ... VN(I)] -> V}}
38
39<procedure>TAGvector-quick-sort! :: V * ELT< [ * START * END] -> V</procedure>
40
41where {{F :: i1 * V(i1) * i2 * V(i2) -> boolean}}
42
43== Examples
44
45
46 csi> (f64vector-map (lambda (v) (* 2 v)) (f64vector 1 2 3))
47 -> #f64(2.0 4.0 6.0)
48 
49 csi> (f64vector-fold (lambda (v ax) (+ v ax)) (f64vector 1 2 3) 0)
50 -> 6.0
51 
52 ;; input vector is modified
53 csi> (f64vector-quick-sort! (f64vector 1 4 2 3) (lambda (i1 v1 i2 v2) (< v1 v2)))
54 #f64(1.0 2.0 3.0 4.0)
55
56== About this egg
57
58
59=== Author
60
61[[/users/ivan-raikov|Ivan Raikov]]
62
63=== Version history
64
65; 1.6 : Documentation converted to wiki format
66; 1.5 : Ported to Chicken 4
67; 1.4 : Build script bug fix
68; 1.3 : Build script updated for better cross-platform compatibility
69; 1.2 : Extended  fold and map interface to support multiple vector arguments
70; 1.1 : Added foldi and mapi procedures
71; 1.0 : Initial release
72
73
74=== License
75
76
77 Copyright 2007-2010 Ivan Raikov and the Okinawa Institute of Science and Technology
78 
79 This program is free software: you can redistribute it and/or modify
80 it under the terms of the GNU General Public License as published by
81 the Free Software Foundation, either version 3 of the License, or (at
82 your option) any later version.
83 
84 This program is distributed in the hope that it will be useful, but
85 WITHOUT ANY WARRANTY; without even the implied warranty of
86 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
87 General Public License for more details.
88 
89 A full copy of the GPL license can be found at
90 <http://www.gnu.org/licenses/>.
91
Note: See TracBrowser for help on using the repository browser.