13 |
12 |
14 fun foldr'' f (l,f2) = let fun itr [] = raise Fail "foldr''" |
13 fun foldr'' f (l,f2) = let fun itr [] = raise Fail "foldr''" |
15 | itr [a] = f2 a |
14 | itr [a] = f2 a |
16 | itr (a::l) = f(a, itr l) |
15 | itr (a::l) = f(a, itr l) |
17 in itr l end; |
16 in itr l end; |
18 fun map_cumulr f start xs = foldr (fn (x,(ys,res))=>case f(x,res) of (y,res2) => |
17 fun map_cumulr f start xs = List.foldr (fn (x,(ys,res))=>case f(x,res) of (y,res2) => |
19 (y::ys,res2)) ([],start) xs; |
18 (y::ys,res2)) ([],start) xs; |
20 |
19 |
21 |
20 |
22 fun first (x,_,_) = x; fun second (_,x,_) = x; fun third (_,_,x) = x; |
21 fun first (x,_,_) = x; fun second (_,x,_) = x; fun third (_,_,x) = x; |
23 fun upd_first f (x,y,z) = (f x, y, z); |
22 fun upd_first f (x,y,z) = (f x, y, z); |