Mercurial > urweb
comparison lib/ur/list.ur @ 839:b2413e4dd109
List library additions; fix another substructure unification bug
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 06 Jun 2009 14:09:30 -0400 |
parents | d07980bf1444 |
children | e4a02e4fa35c |
comparison
equal
deleted
inserted
replaced
838:5154a047c6bc | 839:b2413e4dd109 |
---|---|
120 case f x st of | 120 case f x st of |
121 (y, st) => fold (y :: ls') st ls | 121 (y, st) => fold (y :: ls') st ls |
122 in | 122 in |
123 fold [] | 123 fold [] |
124 end | 124 end |
125 | |
126 fun assoc [a] [b] (_ : eq a) (x : a) = | |
127 let | |
128 fun assoc' ls = | |
129 case ls of | |
130 [] => None | |
131 | (y, z) :: ls => | |
132 if x = y then | |
133 Some z | |
134 else | |
135 assoc' ls | |
136 in | |
137 assoc' | |
138 end | |
139 | |
140 fun search [a] [b] f = | |
141 let | |
142 fun search' ls = | |
143 case ls of | |
144 [] => None | |
145 | x :: ls => | |
146 case f x of | |
147 None => search' ls | |
148 | v => v | |
149 in | |
150 search' | |
151 end | |
152 |