Boost logo

Boost :

Subject: Re: [boost] Interest in a list comprehension library?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-12-19 20:54:55


On 12/19/10 12:40, Brent Spillner wrote:
> I uploaded sample code to the Vault (in the "Miscellaneous/"
> directory) that provides a concise notation for list comprehensions.
> The comprehensions are evaluated lazily and can be used to populate a
> std::list, vector, or deque, appended to the same, inserted after a
> given iterator, or interpreted as a boost::range, including
> compatibility with BOOST_FOREACH. Containers, iterator-defined
> ranges, or nullary function objects can be used as generators, and
> arbitrary function objects can be used to specify filter conditions.

List comprehensions in haskell can be done with monads:

  http://book.realworldhaskell.org/read/monads.html

Why not 1st define a c++ monad and then define the list comprehension
using the moand? If that were done, then boost would have both.
Actually, fcpp already has it in monad.h. Fcpp is available at sourceforge:

 http://sourceforge.net/projects/fcpp/

However, I've not used fcpp and several years ago boost reviewed it
but decided not to include it.

  http://lists.boost.org/Archives/boost/2004/02/61840.php

However, I think defining a monad acceptable to boost would be
useful since it is used extensively in functional programming.

-regards,
 Larry


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk