Functional C++
Function Equivalence | |
---|---|
Haskell | C++ |
map | for_each |
foldl | accumulate |
foldr | accumulate |
filter | copy_if |
replicate | fill_n |
Contents
map
foldl
foldr
filter
replicate
template <class OutputIterator, class Size, class T>
OutputIterator fill_n (OutputIterator first, Size n, const T& val)
{
while (n>0) {
*first = val;
++first; --n;
}
return first;
}