comparison src/list_util.sml @ 39:02f42e9a1825

Corify removes modules
author Adam Chlipala <adamc@hcoop.net>
date Thu, 19 Jun 2008 12:39:22 -0400
parents 44b5405e74c7
children 3739af9e727a
comparison
equal deleted inserted replaced
38:d16ef24de78b 39:02f42e9a1825
78 end 78 end
79 in 79 in
80 fm ([], s) 80 fm ([], s)
81 end 81 end
82 82
83 fun foldlMapConcat f s =
84 let
85 fun fm (ls', s) ls =
86 case ls of
87 nil => (rev ls', s)
88 | h :: t =>
89 let
90 val (h', s') = f (h, s)
91 in
92 fm (List.revAppend (h', ls'), s') t
93 end
94 in
95 fm ([], s)
96 end
97
98 fun foldlMapPartial f s =
99 let
100 fun fm (ls', s) ls =
101 case ls of
102 nil => (rev ls', s)
103 | h :: t =>
104 let
105 val (h', s') = f (h, s)
106 val ls' = case h' of
107 NONE => ls'
108 | SOME h' => h' :: ls'
109 in
110 fm (ls', s') t
111 end
112 in
113 fm ([], s)
114 end
115
83 fun search f = 116 fun search f =
84 let 117 let
85 fun s ls = 118 fun s ls =
86 case ls of 119 case ls of
87 [] => NONE 120 [] => NONE