On Thu, Dec 16, 2004 at 12:03:24PM +0000, Richard Jones wrote:
> On Thu, Dec 16, 2004 at 10:22:05AM +0100, Nicolas Cannasse wrote:
> > Hi list,
> > It's been long time without activity on this list, I have been quite busy
> > lately but I keep on fixing bugs when reports are coming sometimes ;). Right
> > now the ExtLib acheivements are pretty good : I am a happy ExtLib user and I
> > don't feel anymore when I write Ocaml that I miss all theses functions from
> > Stdlib. That's good, and I hope you feel same.
> > As for the future, I am not certain which path we should follow. I tend to
> > appreciate the current shape of ExtLib and I'm not wishing to include a lot
> > more modules, but other people might think different. What I would like to
> > be included in ExtLib would be small Xml and Date modules, but I'm not sure
> > we can reach agreement on what should be put inside theses ;). Any insights
> > or wishes are welcome !
> ExtLib works great for me. The only thing I'd like to see is more of
> the same. Some ideas:
> List.takewhile and List.dropwhile still seem to be missing (I posted a
> patch for this on list some time ago).
> Simple config file parsing. YAML-compatibility would be awesome. Or
> take a look at ConfigParser in JG's MissingLib.
> let rec range a b =
> if a <= b then
> a :: range (a+1) b
IMO, it's usually a bad idea to make both ends of a range
inclusive, because you usually use a length to either
derive the endpoints or expect the number of returned
elements to be (b-a).
... and wouldn't range be better as an Enum constructor?
> let truncate ?(with_dots = false) ?(dots = " ...") n str =
> if String.length str < n then
> else (
> if not with_dots then
> String.sub str 0 n
> else (
> let n = n - String.length dots in
> let str = String.sub str 0 n in
> str ^ dots
I'm not sure this is "generally useful" in any meaningful
When you need to truncate (with dots) you usually want
more control, eg. truncation of paths would usually
truncate some characters in the middle.
In the simple case (without dots) you can just use
String.slice (which will never throw an excpetion, just
> From this you can have trimming functions:
> let triml ?(test = isspace) str = ...
> let trimr ?(test = isspace) str = ...
> let trim ?test str = ...
... or lstrip/rstrip/strip as they would be known
according to the current naming conventions. :)
The fact that trim takes a "test" closure instead of
string with characters should IMHO be regarded as a
feature and the 'old' strip should just be removed... Of
course it may mean that the compiler cannot inline the
"test" calls, but that is, again IMHO, a compiler issue.
> List.uniq and List.sort_uniq:
> let rec uniq ?(cmp = Pervasives.compare) = function
>  -> 
> | [x] -> [x]
> | x :: y :: xs when compare x y = 0 ->
^--- you mean "cmp", right?
> uniq (x :: xs)
> | x :: y :: xs ->
> x :: uniq (y :: xs)
> let sort_uniq ?cmp xs =
> let xs = List.sort ?cmp xs in
> let xs = uniq ?cmp xs in
- Slow down, sir! You're going to give yourself skin failure!
Dr. Nick | The Simpsons