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

Bug#387526: libmissinglib-ocaml-dev: Add List.map_some



Package: libmissinglib-ocaml-dev
Severity: wishlist

For the record.

---------- 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 

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-2-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8)



Reply to: