home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-09-24 | 632 b | 24 lines | [TEXT/ttxt] |
- (**************** A few general-purpose functions *******************)
-
- let fold f = fold_rec where rec fold_rec a1 = function
- [] -> (a1,[])
- | b1::bl ->
- let (a2,c2) = f a1 b1 in
- let (a,cl) = fold_rec a2 bl in
- (a, c2::cl)
- ;;
-
- let try_find f = try_find_rec where rec try_find_rec = function
- [] -> failwith "try_find"
- | a::L -> try f a with Failure _ -> try_find_rec L
- ;;
-
- let partition p = part_rec where rec part_rec = function
- [] -> [],[]
- | a::L -> let (pos,neg) = part_rec L in
- if p a then a::pos, neg else pos, a::neg
- ;;
-
- let message s = print_string s; print_newline()
- ;;
-