I'm pretty sure the Ocaml code is doing more than the Python code you posted. Hopefully someone who knows Ocaml can explain it to us and then we can write the actual python equivalent.
start env = function
| [] -> ()
| line :: lines
when String.length line > 4 && String.sub line 0 3 = "+++" ->
header env line;
modified env 0 lines
| _ :: lines -> start env lines
is a bit elitist way to write a 2 argument function as a combination of 1 argument function and a lambda function. So let me rewrite:
start (env) (list) = match list with
| [] -> ()
| line :: lines
when String.length line > 4 && String.sub line 0 3 = "+++" ->
header env line;
modified env 0 lines
| _ :: lines -> start env lines
So the function `start` takes some kind of state `env` as a first argument, and then it takes a list as a second argument, here named `list`.
If the list is empty, [], it does nothing.
If the first list element, which is a string, starts with "+++", it calls two other functions: first header(env,line) where `line` is now the first list element, and then modified(env,0,lines) where `lines` is the rest of the list, not containing the first element.
If the first list element does not start with +++, it recurses to the rest of the list.
So this is not a filter: After first encounter of "+++" it calls those two other functions and stops.
The ocaml standard library is minimal to a fault. It's just enough to implement the compiler itself. For higher level operations like starts_with, you use libraries. The Batteries library for example provides what you want:
It's a problem. Until people have standardized on which 'better standard library' to use, programs will keep building from these too low level building blocks.
It is a style, not a problem. OCaml had been there a long long time. I've brushed with it a couple of times over the years, and every time the same thing.
You look at some random OCaml code, and it looks like this:
when String.length line > 4 && String.sub line 0 3 = "+++"
I'm looking at it, and I'm not even sure - is it a bug there? Should it be '>=3' or they've really wanted to say '> 4'. Numbers all other the place? Ten different variants of equal signs?
You can call it a style if that makes a difference. I think there are reasons behind that style, and I think the too minimal standard library is the main reason. The lack of a good package manager until recently may be another contributing reason.
I hesitate to answer your hyperbole about ten variants of equal signs. It's not uncommon for languages to have two notions of equality like ocaml has (or even more): Here's Python for example:
http://stackoverflow.com/questions/132988/is-there-a-differe...
To answer your original question of why anyone would prefer to not use startswith: I don't think anyone does.