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/FLINT/opt/optutils.sml
ViewVC logotype

Diff of /sml/trunk/src/compiler/FLINT/opt/optutils.sml

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

revision 199, Wed Nov 25 18:30:38 1998 UTC revision 202, Sun Dec 13 02:29:45 1998 UTC
# Line 17  Line 17 
17      (* A less brain-dead version of ListPair.all: returns false if      (* A less brain-dead version of ListPair.all: returns false if
18       * length l1 <> length l2 *)       * length l1 <> length l2 *)
19      val ListPair_all : ('a * 'b -> bool) -> 'a list * 'b list -> bool      val ListPair_all : ('a * 'b -> bool) -> 'a list * 'b list -> bool
20    
21        (* This is not a proper transposition in that the order is reversed
22         * in the following way:  transpose x = map rev (proper_trans x) *)
23        exception Unbalanced
24        val transpose : 'a list list -> 'a list list
25        val foldl3 : ('a * 'b * 'c * 'd -> 'd) -> 'd -> 'a list * 'b list * 'c list -> 'd
26  end  end
27    
28  structure OptUtils :> OPT_UTILS =  structure OptUtils :> OPT_UTILS =
# Line 50  Line 56 
56          in allp          in allp
57          end          end
58    
59        exception Unbalanced
60        fun transpose [] = []
61          | transpose (xs::xss) =
62            let fun tr [] accs = accs
63                  | tr (xs::xss) accs =
64                    let fun f [] [] = []
65                          | f (x::xs) (acc::accs) = (x::acc)::(f xs accs)
66                          | f _ _ = raise Unbalanced
67                    in tr xss (f xs accs)
68                    end
69            in tr xss (map (fn x => [x]) xs)
70            end
71    
72        fun foldl3 f =
73            let fun l s ([],[],[]) = s
74                  | l s (x1::x1s,x2::x2s,x3::x3s) = l (f(x1,x2,x3,s)) (x1s,x2s,x3s)
75                  | l _ _ = raise Unbalanced
76            in l
77            end
78    
79  end  end
80  end  end

Legend:
Removed from v.199  
changed lines
  Added in v.202

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