--- roparzhhemon < roparzhhemon%40yahoo.com.br">roparzhhemon
yahoo.com.br> wrote:
> If I understood the original question correctly, the point was to
> create a "polymorphic"
> function that works as well, say, on ["a";"b";"c";"d"] as on
> [1;2;3;4]. This is why the
> *list* l (and not just its length n) is an argument in my function.
I did not understand the question that way, but it is a minor
difference.
In case it was not clear, my point was that 1 and l, as 0 and O look
very similar when rendered with certain fonts that are common for
source code editing. So it is a bad idea to use them as variable
names if you aim for readability.
PS:
let cons h t = h::t;;
let rec comb es k = match (es, k) with
| ([], 0) -> [[]]
| ([], _) -> []
| (h::t, _) ->
List.rev_append
(List.map (cons h) (comb t (k-1)))
(comb t k);;
__________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
.