feat(util/list_fn): add remove function

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-06-26 09:03:04 -07:00
parent da6e92787a
commit ab2bbaef3f

View file

@ -176,6 +176,12 @@ list<T> filter(list<T> const & l, P && p) {
} }
} }
/** \brief Remove all occurrences of \c a from \c l */
template<typename T>
list<T> remove(list<T> const & l, T const & a) {
return filter(l, [&](T const & v) { return a != v; });
}
/** \brief Remove the last element that satisfies \c p. */ /** \brief Remove the last element that satisfies \c p. */
template<typename T, typename P> template<typename T, typename P>
list<T> remove_last(list<T> const & l, P && p) { list<T> remove_last(list<T> const & l, P && p) {