[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Missing: List.map_some (fwd)





---------- Forwarded message ----------
Date: Thu, 14 Sep 2006 13:46:14 -0500
From: John Goerzen <jgoerzen@complete.org>
To: Ivan Jager <aij+nospam@andrew.cmu.edu>
Subject: Re: Missing: List.map_some

Hi Ivan,

Thanks for the patch.  Unfortunately, I'm no longer maintaining
missinglib since I no longer use OCaml (switched to Haskell).  However,
the Debian OCaml Team is maintaining a branch of it, so you may want to
contact them at debian-ocaml-maint@lists.debian.org.

-- John

On Thu, Sep 14, 2006 at 02:40:40PM -0400, Ivan Jager wrote:
Could you add this function to missinglib?

In many of my ocaml programs, I end up writing this function (or
something equivalent):

(* Should be in List *)
let list_map_some f l =
  let rec m n o =
    match o with
	[] -> n
      | x::xs ->
	  (match f x with
	       Some v -> m (v::n) xs
	     | None -> m n xs )
  in List.rev(m [] l)


The last time I wrote that function, I had a typo, which cost me a few
hours of debugging other code before I found what was going on.

Thanks,
Ivan




Reply to: