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

Last change on this file since 25596 was 25596, checked in by Ivan Raikov, 9 years ago

applied patch for #733 [thanks to Mario Domenech Goulart]

File size: 4.8 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<procedure>s8vector-fold :: F * X0 * V [* V1 ... VN] -> XN</procedure><br>
22<procedure>u8vector-fold :: F * X0 * V [* V1 ... VN] -> XN</procedure><br>
23<procedure>s16vector-fold :: F * X0 * V [* V1 ... VN] -> XN</procedure><br>
24<procedure>u16vector-fold :: F * X0 * V [* V1 ... VN] -> XN</procedure><br>
25<procedure>s32vector-fold :: F * X0 * V [* V1 ... VN] -> XN</procedure><br>
26<procedure>u32vector-fold :: F * X0 * V [* V1 ... VN] -> XN</procedure><br>
27<procedure>f32vector-fold :: F * X0 * V [* V1 ... VN] -> XN</procedure><br>
28<procedure>f64vector-fold :: F * X0 * V [* V1 ... VN] -> XN</procedure>
29
30where {{F :: V(I) [ * V1(I) ... VN(I)] * AX -> AX}}
31
32<procedure>s8vector-map :: F * V [ * V1 ... VN] -> V</procedure><br>
33<procedure>u8vector-map :: F * V [ * V1 ... VN] -> V</procedure><br>
34<procedure>s16vector-map :: F * V [ * V1 ... VN] -> V</procedure><br>
35<procedure>u16vector-map :: F * V [ * V1 ... VN] -> V</procedure><br>
36<procedure>s32vector-map :: F * V [ * V1 ... VN] -> V</procedure><br>
37<procedure>u32vector-map :: F * V [ * V1 ... VN] -> V</procedure><br>
38<procedure>f32vector-map :: F * V [ * V1 ... VN] -> V</procedure><br>
39<procedure>f64vector-map :: F * V [ * V1 ... VN] -> V</procedure>
40
41<procedure>s8vector-foldi :: F * X0 * V [ * V1 ... VN] -> XN</procedure><br>
42<procedure>u8vector-foldi :: F * X0 * V [ * V1 ... VN] -> XN</procedure><br>
43<procedure>s16vector-foldi :: F * X0 * V [ * V1 ... VN] -> XN</procedure><br>
44<procedure>u16vector-foldi :: F * X0 * V [ * V1 ... VN] -> XN</procedure><br>
45<procedure>s32vector-foldi :: F * X0 * V [ * V1 ... VN] -> XN</procedure><br>
46<procedure>u32vector-foldi :: F * X0 * V [ * V1 ... VN] -> XN</procedure><br>
47<procedure>f32vector-foldi :: F * X0 * V [ * V1 ... VN] -> XN</procedure><br>
48<procedure>f64vector-foldi :: F * X0 * V [ * V1 ... VN] -> XN</procedure>
49
50where {{F :: I * V(I) [ * V1(I) ... VN(I)] * AX -> AX}}
51
52
53<procedure>s8vector-mapi :: F * V [* V1 ... VN] -> V</procedure><br>
54<procedure>u8vector-mapi :: F * V [* V1 ... VN] -> V</procedure><br>
55<procedure>s16vector-mapi :: F * V [* V1 ... VN] -> V</procedure><br>
56<procedure>u16vector-mapi :: F * V [* V1 ... VN] -> V</procedure><br>
57<procedure>s32vector-mapi :: F * V [* V1 ... VN] -> V</procedure><br>
58<procedure>u32vector-mapi :: F * V [* V1 ... VN] -> V</procedure><br>
59<procedure>f32ector-mapi :: F * V [* V1 ... VN] -> V</procedure><br>
60<procedure>f64vector-mapi :: F * V [* V1 ... VN] -> V</procedure>
61
62where {{F :: I * V(I) [* V1(I) ... VN(I)] -> V}}
63
64
65<procedure>s8vector-quick-sort! :: V * ELT< [ * START * END] -> V</procedure><br>
66<procedure>u8vector-quick-sort! :: V * ELT< [ * START * END] -> V</procedure><br>
67<procedure>s16vector-quick-sort! :: V * ELT< [ * START * END] -> V</procedure><br>
68<procedure>u16vector-quick-sort! :: V * ELT< [ * START * END] -> V</procedure><br>
69<procedure>s32vector-quick-sort! :: V * ELT< [ * START * END] -> V</procedure><br>
70<procedure>u32vector-quick-sort! :: V * ELT< [ * START * END] -> V</procedure><br>
71<procedure>f32vector-quick-sort! :: V * ELT< [ * START * END] -> V</procedure><br>
72<procedure>f64vector-quick-sort! :: V * ELT< [ * START * END] -> V</procedure>
73
74where {{F :: i1 * V(i1) * i2 * V(i2) -> boolean}}
75
76
77== Examples
78
79
80 csi> (f64vector-map (lambda (v) (* 2 v)) (f64vector 1 2 3))
81 -> #f64(2.0 4.0 6.0)
82 
83 csi> (f64vector-fold (lambda (v ax) (+ v ax)) (f64vector 1 2 3) 0)
84 -> 6.0
85 
86 ;; input vector is modified
87 csi> (f64vector-quick-sort! (f64vector 1 4 2 3) (lambda (i1 v1 i2 v2) (< v1 v2)))
88 #f64(1.0 2.0 3.0 4.0)
89
90== About this egg
91
92
93=== Author
94
95[[/users/ivan-raikov|Ivan Raikov]]
96
97=== Version history
98
99; 1.6 : Documentation converted to wiki format
100; 1.5 : Ported to Chicken 4
101; 1.4 : Build script bug fix
102; 1.3 : Build script updated for better cross-platform compatibility
103; 1.2 : Extended  fold and map interface to support multiple vector arguments
104; 1.1 : Added foldi and mapi procedures
105; 1.0 : Initial release
106
107
108=== License
109
110
111 Copyright 2007-2010 Ivan Raikov and the Okinawa Institute of Science and Technology
112 
113 This program is free software: you can redistribute it and/or modify
114 it under the terms of the GNU General Public License as published by
115 the Free Software Foundation, either version 3 of the License, or (at
116 your option) any later version.
117 
118 This program is distributed in the hope that it will be useful, but
119 WITHOUT ANY WARRANTY; without even the implied warranty of
120 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
121 General Public License for more details.
122 
123 A full copy of the GPL license can be found at
124 <http://www.gnu.org/licenses/>.
125
Note: See TracBrowser for help on using the repository browser.