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 /smlnj-lib/trunk/Util/dynamic-array-fn.sml
ViewVC logotype

Diff of /smlnj-lib/trunk/Util/dynamic-array-fn.sml

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

revision 3795, Sun Oct 28 17:20:47 2012 UTC revision 3796, Tue Oct 30 10:09:07 2012 UTC
# Line 10  Line 10 
10    struct    struct
11    
12      type elem = A.elem      type elem = A.elem
13    
14      (* BLOCK(arr, dflt, bnd):
15       *    arr     - current data store; is at least !bnd+1 elements
16       *    dflt    - default value
17       *    bnd     - values at !bnd and above are default for reading
18       *)
19      datatype array = BLOCK of A.array ref * elem * int ref      datatype array = BLOCK of A.array ref * elem * int ref
20    
21      exception Subscript = General.Subscript      exception Subscript = General.Subscript
# Line 22  Line 28 
28     * NOTE: Once MONO_ARRAY includes arrayoflist, this will become trivial.     * NOTE: Once MONO_ARRAY includes arrayoflist, this will become trivial.
29     *)     *)
30      fun fromList (initList, dflt) = let      fun fromList (initList, dflt) = let
31            val len = length initList            val arr = A.fromList initList
           val arr = A.array(len, dflt)  
           fun upd ([], _) = ()  
             | upd (x::r, i) = (A.update(arr, i, x); upd(r, i+1))  
32            in            in
33              upd (initList, 0);              BLOCK(ref arr, dflt, ref(A.length arr - 1))
             BLOCK(ref arr, dflt, ref (len-1))  
34            end            end
35    
36    (* tabulate (sz,fill,dflt) acts like Array.tabulate, plus    (* tabulate (sz,fill,dflt) acts like Array.tabulate, plus

Legend:
Removed from v.3795  
changed lines
  Added in v.3796

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