Browse thread
recursion/iterator question
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-04-18 (03:25) |
From: | Jonathan Roewen <jonathan.roewen@g...> |
Subject: | Re: [Caml-list] recursion/iterator question |
> > let rec combs = function > > > > | (0, _) -> [[]] > > | (n, es) when n > List.length es -> [] > > | (n, e::es) -> List.map (fun l -> e::l) (combs (n-1, es)) @ combs > > | (n, es) > > > > let triplets es = combs (3, es) > > > > Question to the rest of the list: The ocaml compiler complains with > > ... > > Warning P: this pattern-matching is not exhaustive. > > Here is an example of a value that is not matched: > > (1, []) > > (However, some guarded clause may match this value.) Personally, if you know it can never be reached, then an assertion is probably better. | otherwise -> assert false (* I prefer using a name like otherwise rather than _ for pure readability value *) Jonathan