151 |
(* val getItem : slice -> (elem * slice) option *) |
(* val getItem : slice -> (elem * slice) option *) |
152 |
fun getItem (SL{base,start,stop}) = |
fun getItem (SL{base,start,stop}) = |
153 |
if stop<=start then NONE |
if stop<=start then NONE |
154 |
else SOME(sub'(base, j'), SL{base,start+1,stop}) |
else SOME(sub'(base, j'), SL{base=base,start=start+1,stop=stop}) |
|
|
|
|
end |
|
155 |
|
|
156 |
(* val appi : (int * elem -> unit) -> slice -> unit *) |
(* val appi : (int * elem -> unit) -> slice -> unit *) |
157 |
fun appi f (SL{base,start,stop}) = |
fun appi f (SL{base,start,stop}) = |
162 |
end |
end |
163 |
|
|
164 |
(* val app : (elem -> unit) -> slice -> unit *) |
(* val app : (elem -> unit) -> slice -> unit *) |
165 |
fun appi f (SL{base,start,stop} = |
fun appi f (SL{base,start,stop}) = |
166 |
let fun app i = if (i < stop) |
let fun app i = if (i < stop) |
167 |
then (f (sub'(base, i)); app(i+1)) |
then (f (sub'(base, i)); app(i+1)) |
168 |
else () |
else () |
170 |
end |
end |
171 |
|
|
172 |
(* val mapi : (int * elem -> 'b) -> slice -> vector *) |
(* val mapi : (int * elem -> 'b) -> slice -> vector *) |
173 |
fun mapi f (SL{base,start,stop} = |
fun mapi f (SL{base,start,stop}) = |
174 |
let val len = stop - start |
let val len = stop - start |
175 |
fun mapf (i, l) = if (i < stop) |
fun mapf (i, l) = if (i < stop) |
176 |
then mapf (i+1, f (i, sub'(base, i)) :: l) |
then mapf (i+1, f (i, sub'(base, i)) :: l) |
181 |
end |
end |
182 |
|
|
183 |
(* val map : (elem -> 'b) -> slice -> vector *) |
(* val map : (elem -> 'b) -> slice -> vector *) |
184 |
fun map f (SL{base,start,stop} = |
fun map f (SL{base,start,stop}) = |
185 |
let val len = stop - start |
let val len = stop - start |
186 |
fun mapf (i, l) = if (i < stop) |
fun mapf (i, l) = if (i < stop) |
187 |
then mapf (i+1, f (sub'(base, i)) :: l) |
then mapf (i+1, f (sub'(base, i)) :: l) |
277 |
let fun cmp (i,i') = |
let fun cmp (i,i') = |
278 |
if (i < stop) |
if (i < stop) |
279 |
then if (i' >= stop') then GREATER |
then if (i' >= stop') then GREATER |
280 |
else case comp(sub'(base, i)), |
else case comp(sub'(base, i), |
281 |
sub'(base', i')) |
sub'(base', i')) |
282 |
of EQUAL => cmp(i+1,i'+1) |
of EQUAL => cmp(i+1,i'+1) |
283 |
| x => x |
| x => x |
286 |
in cmp(start,start') |
in cmp(start,start') |
287 |
end |
end |
288 |
|
|
|
end (* structure Word8VectorSlice *) |
|
289 |
end (* structure Word8ArraySlice *) |
end (* structure Word8ArraySlice *) |