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/trunk/src/compiler/PervEnv/Basis/array2.sml
ViewVC logotype

Diff of /sml/trunk/src/compiler/PervEnv/Basis/array2.sml

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

revision 113, Fri Jun 5 19:41:21 1998 UTC revision 167, Sat Nov 7 20:11:41 1998 UTC
# Line 46  Line 46 
46             of 0 => {data = Assembly.array0, nrows = 0, ncols = 0}             of 0 => {data = Assembly.array0, nrows = 0, ncols = 0}
47              | n => {data = mkArray (n, v), nrows = nrows, ncols = ncols}              | n => {data = mkArray (n, v), nrows = nrows, ncols = ncols}
48            (* end case *))            (* end case *))
49      fun fromList [] = {data = Assembly.array0, nrows = 0, ncols = 0}      fun fromList rows = (case List.rev rows
50        | fromList (row1 :: rest) = let             of [] => {data = Assembly.array0, nrows = 0, ncols = 0}
51            val ncols = List.length row1              | (lastRow::rest) => let
52            fun chk ([], nrows, l) = (nrows, l)                  val nCols = List.length lastRow
53              | chk (row::rest, nrows, l) = let                  fun chk ([], nRows, l) = (nRows, l)
54                  fun chkRow ([], n, revCol) = (                    | chk (row::rest, nRows, l) = let
55                        if (n <> ncols) then raise General.Size else ();                        fun chkRow ([], n) = (
56                        List.revAppend (revCol, l))                              if (n <> nCols) then raise General.Size else ();
57                    | chkRow (x::r, n, revCol) = chkRow (r, n+1, x::revCol)                              l)
58                  in                          | chkRow (x::r, n) = x :: chkRow(r, n+1)
59                    chk (rest, nrows+1, chkRow(row, 0, []))                        in
60                  end                          chk (rest, nRows+1, chkRow(row, 0))
61            val (nrows, flatList) = chk (rest, 1, [])                        end
62            in                  val (nRows, data) = chk(rest, 1, lastRow)
63              { data = Array.fromList(List.@(row1, flatList)),                  in
64                nrows = nrows, ncols = ncols                    {data = Array.fromList data, nrows = nRows, ncols = nCols}
             }  
65            end            end
66              (* end case *))
67      fun tabulateRM (nrows, ncols, f) = (case chkSize (nrows, ncols)      fun tabulateRM (nrows, ncols, f) = (case chkSize (nrows, ncols)
68             of 0 => {data = Assembly.array0, nrows = nrows, ncols = ncols}             of 0 => {data = Assembly.array0, nrows = nrows, ncols = ncols}
69              | n => let              | n => let
# Line 115  Line 115 
115            in            in
116              if ltu(nrows, i)              if ltu(nrows, i)
117                then raise General.Subscript                then raise General.Subscript
118                else mkVec (stop+nrows-1, [])                else mkVec (stop+ncols-1, [])
119            end            end
120      fun column ({data, nrows, ncols}, j) = let      fun column ({data, nrows, ncols}, j) = let
121            fun mkVec (i, l) =            fun mkVec (i, l) =
# Line 289  Line 289 
289    end    end
290    
291  (*  (*
292   * $Log$   * $Log: array2.sml,v $
293     * Revision 1.2  1998/08/21 17:28:58  jhr
294     *   Fixed bug in row function.
295     *
296     * Revision 1.1.1.1  1998/04/08 18:40:03  george
297     * Version 110.5
298     *
299   *)   *)

Legend:
Removed from v.113  
changed lines
  Added in v.167

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