Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/branches/idlbasis-devel/src/system/Basis/Implementation/vector-slice.sml
ViewVC logotype

Diff of /sml/branches/idlbasis-devel/src/system/Basis/Implementation/vector-slice.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 865, Sat Jun 30 03:40:12 2001 UTC revision 866, Mon Jul 2 16:33:10 2001 UTC
# Line 56  Line 56 
56    
57  (* val full : 'a Vector.vector -> 'a slice *)  (* val full : 'a Vector.vector -> 'a slice *)
58    fun full base = SL{base=base,start=0,stop=V.length base}    fun full base = SL{base=base,start=0,stop=V.length base}
59    (*
60        let val blen = V.length base        let val blen = V.length base
61         in if geu(start, blen)  (* checks start >= 0 *)         in if geu(start, blen)  (* checks start >= 0 *)
62            then raise Core.Subscript            then raise Core.Subscript
# Line 66  Line 67 
67                        then raise Core.Subscript                        then raise Core.Subscript
68                        else SL{base=base,start=start,stop=start+n}                        else SL{base=base,start=start,stop=start+n}
69        end        end
70    *)
71    
72  (* val subslice : 'a slice * int * int option -> 'a slice *)  (* val subslice : 'a slice * int * int option -> 'a slice *)
73    fun subslice (SL{base, start, stop}, i, sz) =    fun subslice (SL{base, start, stop}, i, sz) =
# Line 83  Line 85 
85    
86  (* val vector : 'a slice -> 'a Vector.vector *)  (* val vector : 'a slice -> 'a Vector.vector *)
87    fun vector (SL{base,start,stop}) =    fun vector (SL{base,start,stop}) =
88        Vector.tabulate((fn n => sub'(base,n+start)),        Vector.tabulate(stop-start,fn n => sub'(base,n+start))
                       stop-start)  
89    
90  (* utility functions *)  (* utility functions *)
91    fun checkLen n =    fun checkLen n =
# Line 121  Line 122 
122  (* val getItem : 'a slice -> ('a * 'a slice) option *)  (* val getItem : 'a slice -> ('a * 'a slice) option *)
123    fun getItem (SL{base,start,stop}) =    fun getItem (SL{base,start,stop}) =
124        if stop<=start then NONE        if stop<=start then NONE
125        else SOME(sub'(base, j'), SL{base=base,start=start+1,stop=stop})        else SOME(sub'(base, start), SL{base=base,start=start+1,stop=stop})
126    
127  (* val appi : (int * 'a -> unit) -> 'a slice -> unit *)  (* val appi : (int * 'a -> unit) -> 'a slice -> unit *)
128    fun appi f (SL{base,start,stop}) =    fun appi f (SL{base,start,stop}) =
# Line 132  Line 133 
133        end        end
134    
135  (* val app  : ('a -> unit) -> 'a slice -> unit *)  (* val app  : ('a -> unit) -> 'a slice -> unit *)
136    fun appi f (SL{base,start,stop}) =    fun app f (SL{base,start,stop}) =
137        let fun app i = if (i < stop)        let fun app i = if (i < stop)
138                then (f (sub'(base, i)); app(i+1))                then (f (sub'(base, i)); app(i+1))
139                else ()                else ()
# Line 214  Line 215 
215                then let val item = sub'(base, i)                then let val item = sub'(base, i)
216                      in if f item                      in if f item
217                         then SOME(item)                         then SOME(item)
218                         else findi' (i+1)                         else find' (i+1)
219                     end                     end
220                else NONE                else NONE
221         in find' start         in find' start

Legend:
Removed from v.865  
changed lines
  Added in v.866

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0