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/word8-array.sml
ViewVC logotype

Diff of /sml/branches/idlbasis-devel/src/system/Basis/Implementation/word8-array.sml

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

revision 862, Thu Jun 28 02:43:07 2001 UTC revision 863, Thu Jun 28 20:41:28 2001 UTC
# Line 65  Line 65 
65      val sub    = A.chkSub      val sub    = A.chkSub
66      val update = A.chkUpdate      val update = A.chkUpdate
67    
68    (*
69      fun extract (v, base, optLen) = let      fun extract (v, base, optLen) = let
70            val len = length v            val len = length v
71            fun newVec n = let            fun newVec n = let
# Line 92  Line 93 
93                      else newVec n                      else newVec n
94              (* end case *)              (* end case *)
95            end            end
96    *)
97    
98      fun vector a = extract (a, 0, NONE)      fun vector a = let
99            val len = length a
100        in
101            if 0 < len then let
102                    val v = V.create len
103                    fun fill i =
104                        if i < len then (vecUpdate (v, i, unsafeSub (a, i));
105                                         fill (i + 1))
106                        else ()
107                in
108                    fill 0;
109                    v
110                end
111            else emptyV
112        end
113    
114        fun copy {src, dst, di} = let
115            val srcLen = length src
116            val sstop = srcLen
117            val dstop = di + srcLen
118            fun copyDown (j, k) =
119                if 0 <= j then
120                    (unsafeUpdate (dst, k, unsafeSub (src, j));
121                     copyDown (j - 1, k - 1))
122                else ()
123        in
124            if di < 0 orelse length dst < dstop then raise Subscript
125            else copyDown (sstop - 1, dstop - 1)
126        end
127  (*  (*
128      fun copy {src, si, len, dst, di} = let      fun copy {src, si, len, dst, di} = let
129            val (sstop, dstop) = let            val (sstop, dstop) = let
# Line 127  Line 156 
156                else copyUp (si, di)                else copyUp (si, di)
157            end            end
158  *)  *)
     fun copy {src, dst, di} = raise Fail "notyet"  
159    
160        fun copyVec {src, dst, di} = let
161            val srcLen = V.length src
162            val sstop = srcLen
163            val dstop = di + srcLen
164            (* assuming that there is no aliasing between vectors and arrays
165             * it should not matter whether we copy up or down... *)
166            fun copyDown (j, k) =
167                if 0 <= j then
168                    (unsafeUpdate (dst, k, vecSub (src, j));
169                     copyDown (j - 1, k - 1))
170                else ()
171        in
172            if di < 0 orelse length dst < dstop then raise Subscript
173            else copyDown (sstop - 1, dstop - 1)
174        end
175  (*  (*
176      fun copyVec {src, si, len, dst, di} = let      fun copyVec {src, si, len, dst, di} = let
177            val (sstop, dstop) = let            val (sstop, dstop) = let
# Line 154  Line 197 
197                else copyUp (si, di)                else copyUp (si, di)
198            end            end
199  *)  *)
     fun copyVec {src, dst, di} = raise Fail "notyet"  
200    
201      fun app f arr = let      fun app f arr = let
202            val len = length arr            val len = length arr

Legend:
Removed from v.862  
changed lines
  Added in v.863

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