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/left-priorityq-fn.sml
ViewVC logotype

Diff of /smlnj-lib/trunk/Util/left-priorityq-fn.sml

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

revision 1076, Tue Feb 19 15:47:18 2002 UTC revision 1081, Thu Feb 21 15:28:03 2002 UTC
# Line 51  Line 51 
51      fun fromList [] = empty      fun fromList [] = empty
52        | fromList [x] = Q (1, singleton x)        | fromList [x] = Q (1, singleton x)
53        | fromList l = let        | fromList l = let
54              fun init ([], n, items) = (n, items)
55                | init (x::r, n, items) = init (r, n+1, singleton x :: items)
56            fun merge ([], [h]) = h            fun merge ([], [h]) = h
57              | merge ([], hl) = merge (hl, [])              | merge ([], hl) = merge (hl, [])
58              | merge ([h], hl) = merge (h::hl, [])              | merge ([h], hl) = merge (h::hl, [])
59              | merge (h1::h2::r, l) = merge (r, mergeHeap(h1, h2) :: l)              | merge (h1::h2::r, l) = merge (r, mergeHeap(h1, h2) :: l)
60              val (len, hs) = init (l, 0, [])
61            in            in
62              Q(List.length l, merge (List.map singleton l, []))              Q(len, merge (hs, []))
63            end            end
64    
65    end;    end;

Legend:
Removed from v.1076  
changed lines
  Added in v.1081

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