From: fva <fv...@ts...> - 2003-02-28 10:20:53
|
Nicolas Cannasse wrote: >>>That would help. Thanks. >>> >>> >>- val String.explode : string -> char list >>- val String.implode : char list -> string >> >> > >Agree > Agree. >> (* like perl's chomp function, remove trailing newline characters *) >>- val String.chomp : string -> string >> >> > >Uhm, why not, but this need some discuss on implementation since newline is >"\r\n" under windows and "\n" under *nix.... > Agree with the consideration for the this double character ending quirks & so. >> (* fold left on file lines (without trailing newline), I don't know in >> which module this functions should go, maybe Sys? *) >>- val fold_file : ('a -> string -> 'a) -> 'a -> string -> 'a >> (* iter on file lines *) >>- val iter_file : (string -> unit) -> string -> unit >> >> > >perhaps : > >val iter_in : (string -> unit) -> in_channel -> unit >val map_in : (string -> 'a) -> in_channel -> 'a list >val fold_in : ('a -> string -> 'a) -> 'a -> in_channel -> 'a > >are better so it can work on many kind of descriptors and does not have to >handle the "file not found" problems > >I propose also : > >val read_lines : in_channel -> string list >val read_all : in_channel -> string > I like better the "in_channel" typed functions. I also use iteri, fold and iter on directories filtering out "." and ".." for doing experiments on many files (based in Unix.opendir, closedir). Haven't looked if the stdlib opted them in for ages... BTW doesn't this look like a pattern on an abstract structure with sequential access? Wouldn't a single signature and a number of structure instantiations be in order here... Ease of use & all that... >that returns all the contents ( up to End_of_file ) > > > >>- val Dbm.fold_left >> >> > >Uh, never used Dbm... > Me neither. Can't judge. >>- val Hashtbl.keys : ('a, 'b) Hashtbl.t -> 'a list >>- val Hashtbl.values : ('a, 'b) Hashtbl.t -> 'b list >> (* remove all bindings of a given keys *) >>- val Hashtbl.remove_all : ('a, 'b) Hashtbl.t -> 'a -> unit >> >> > >Agree > Yes. I also miss those when I've been perling for some time... >> (* like Hashtbl.fold but working on ordered key list. Find a better >> name!, compare defaults to Pervasives.compare *) >>- val Hashtbl.sorted_fold: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> >> >> >'c -> 'c) -> ('a, 'b) Hashtbl.t -> 'c -> 'c > >> (* as above for iter *) >>- val Hashtbl.sorted_iter: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> >> >> >unit) -> ('a, 'b) Hashtbl.t -> unit > >Aren't theses strange and very particular ones ?? > I see the perlmania here as well, but they are worth, for me at least, in *very particular contexts* (text processing). >> (* return all bindings of a given key *) >>- val List.assoc_all: 'a -> ('a * 'b) list -> 'b list >> (* as above but use physical equality *) >>- val List.assq_all: 'a -> ('a * 'b) list -> 'b list >> Yes. I have these in the more general context of "maps". >>- val Sys.copy: src:string -> dst:string -> unit >> >> (* add support for recursive directory creation for Unix.mkdir *) >>- support for "-p" to Unix.mkdir >>- Unix.is_directory : ?follow_sym_link: bool -> string -> bool >>- Unix.is_regular >>- Unix.is_symlink >>- ... (* predicates over filenames, optional argument defaults to false, >> if it is true predicate are over symlink target *) >> (* return size of a given file; maybe Sys.filesize? *) >>- Unix.filesize : string -> bool >> (* "/ls" command interface *) >>- Unix.ls : string -> string list >> >> > >All theses cannot be part of the ExtLib, since we're only focusing right now >on the StdLib Extension ( and Unix is not part of the StdLib altought it's >part of the standard distribution ) and also theses function need some C >code to work. > So no using of Unix, uh? I see: standalone and all that. >>- val Random.char: unit -> char >>- val Random.stringi: int -> char (* argument is string length *) >> >> > >Don't like theses > Don't see the point either, really. >> (* predicate negation *) >>- val non: ('a -> bool) -> ('a -> bool) >> >> > >Since there is some need for such basic functions, let's put that in a >module Logic > Interesting. Agree. >> (* given a 'a option returns the 'a value if it's Some _ or raise an >> exception, find a better name! *) >>- val unsome : 'a option -> 'a >> >> > >Global is much more complete > Think so too. I liked the name "the" for this function, though. It also looks like the iota quantifier and perhaps should go into Logic? Regards, Fran Valverde |