SCM Repository
[smlnj] Annotation of /sml/trunk/benchmarks/todo/vboyer/vector-util.sml
Annotation of /sml/trunk/benchmarks/todo/vboyer/vector-util.sml
Parent Directory
|
Revision Log
Revision 193 -
(view)
(download)
1 : |
monnier |
193 |
structure VectorUtil =
|
2 : |
|
|
struct
|
3 : |
|
|
local
|
4 : |
|
|
open Vector
|
5 : |
|
|
in
|
6 : |
|
|
fun listOfVector v = let
|
7 : |
|
|
fun f (0, l) = l
|
8 : |
|
|
| f (i, l) = f (i-1, Vector.sub(v, i-1) :: l)
|
9 : |
|
|
in
|
10 : |
|
|
f (Vector.length v, [])
|
11 : |
|
|
end
|
12 : |
|
|
fun mapv f = let
|
13 : |
|
|
fun mapv' #[a] = #[f a]
|
14 : |
|
|
| mapv' #[a, b] = #[f a, f b]
|
15 : |
|
|
| mapv' #[a, b, c] = #[f a, f b, f c]
|
16 : |
|
|
| mapv' #[a, b, c, d] = #[f a, f b, f c, f d]
|
17 : |
|
|
| mapv' v = vector (map f (listOfVector v))
|
18 : |
|
|
in
|
19 : |
|
|
mapv'
|
20 : |
|
|
end
|
21 : |
|
|
end
|
22 : |
|
|
end;
|