Name: Anonymous 2009-01-24 17:45
when coming back to C++ after coding quite a bit haskell and python I felt a need for a map function.
my first go at it ended in this:
it's not really as good as I want it to be (forced std::list etc) but the only thing google found was weird implementation with some weird recursive-template lists. anyone got a better one?
also, lul wut textboard
my first go at it ended in this:
template <typename O, typename I, typename func_p>
std::list<O> & map(func_p func, const std::list<I> & in, std::list<O> & out) {
for(typename std::list<I>::const_iterator it = in.begin(); it != in.end(); ++it) {
out.push_back(func(*it));
}
return out;
}it's not really as good as I want it to be (forced std::list etc) but the only thing google found was weird implementation with some weird recursive-template lists. anyone got a better one?
also, lul wut textboard