[
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: | -- (:) |
| From: | Jon Harrop <jon@f...> |
| Subject: | Re: [Caml-list] Amb |
On Friday 09 February 2007 21:55, Brian Hurt wrote: > let rec amb = function > > | [] -> None > | h :: t -> > > let r = > try > Some(h ()) > with > > | _ -> None > > in > match r with > > | None -> amb t > | Some(_) as e -> e > > As a slightly better implementation. I think you're trying to box the returned value in order to evade non-tail recursion but the OPs function was actually already tail recursive because the recursive call to "amb" occurs outside the try..with. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists