CVS: sml-dist/src/system/Basis/Implementation array2.sml,1.2,1.3

Matthias Blume <[email protected]>
Newsgroups gmane.comp.lang.sml.smlnj.commits
Message-ID <[email protected]>
Update of /cvsroot/smlnj/sml-dist/src/system/Basis/Implementation
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10149/src/system/Basis/Implementation

Modified Files:
	array2.sml 
Log Message:
added implementation of Array2.copy

Index: array2.sml
===================================================================
RCS file: /cvsroot/smlnj/sml-dist/src/system/Basis/Implementation/array2.sml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** array2.sml	1 Jun 2000 18:33:58 -0000	1.2
--- array2.sml	16 Nov 2005 04:31:59 -0000	1.3
***************
*** 12,15 ****
--- 12,16 ----
  
      structure A = Array
+     structure AS = ArraySlice
  
      type 'a array = {
***************
*** 146,151 ****
  	  end
  
!     fun copy {src : 'a region, dst, dst_row, dst_col} =
! 	  raise Fail "Array2.copy unimplemented"
  
    (* this function generates a stream of indeces for the given region in
--- 147,182 ----
  	  end
  
!     fun copy {src : 'a region, dst: 'a array, dst_row, dst_col} =
! 	let val _ = chkRegion src
! 	    val { base, row = srow, col = scol,
! 		  nrows = snrows, ncols = sncols } = src
! 	    val { data = bdata, ncols = bncols, nrows = bnrows } = base
! 	    val { data = ddata, ncols = dncols, nrows = dnrows } = dst
! 	    val src_nrows = getOpt (snrows, bnrows - srow)
! 	    val src_ncols = getOpt (sncols, bncols - scol)
! 	    fun dn (i, d, s) =
! 		if i > 0 then
! 		    ((* we might be better off doing this directly
! 		      * instead of calling the ArraySlice module: *)
! 		     AS.copy { src = AS.slice (bdata, s, SOME src_ncols),
! 			       dst = ddata, di = d };
! 		     dn (i-1, d + dncols, s + bncols))
! 		else ()
! 	    fun up (i, d, s) =
! 		if i > 0 then
! 		    (AS.copy { src = AS.slice (bdata, s, SOME src_ncols),
! 			       dst = ddata, di = d };
! 		     up (i-1, d - dncols, s - bncols))
! 		else ()
! 	in if src_nrows + dst_row > dnrows orelse src_ncols + dst_col > dncols
! 	   then raise General.Subscript
! 	   else if dst_row <= srow then
! 	       dn (src_nrows,
! 		   dst_row * dncols + dst_col,
! 		   srow * bncols + scol)
! 	   else up (src_nrows,
! 		    (dst_row + src_nrows - 1) * dncols + dst_col,
! 		    (srow + src_nrows - 1) * bncols + scol)
! 	end
  
    (* this function generates a stream of indeces for the given region in



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.