feat(util/list_fn): add remove function
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
da6e92787a
commit
ab2bbaef3f
1 changed files with 6 additions and 0 deletions
|
@ -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. */
|
||||
template<typename T, typename P>
|
||||
list<T> remove_last(list<T> const & l, P && p) {
|
||||
|
|
Loading…
Reference in a new issue