MCPcopy Create free account
hub / github.com/Dobiasd/FunctionalPlus / take_while

Function take_while

include/fplus/container_common.hpp:842–850  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

840// take_while(is_even, [0,2,4,5,6,7,8]) == [0,2,4]
841template <typename Container, typename UnaryPredicate>
842Container take_while(UnaryPredicate pred, const Container& xs)
843{
844 internal::check_unary_predicate_for_container<UnaryPredicate, Container>();
845 auto itFirst = std::find_if(
846 std::begin(xs), std::end(xs), logical_not(pred));
847 if (itFirst == std::end(xs))
848 return xs;
849 return Container(std::begin(xs), itFirst);
850}
851
852// API search type: take_last_while : ((a -> Bool), [a]) -> [a]
853// fwd bind count: 1

Callers 1

Calls 1

logical_notFunction · 0.70

Tested by

no test coverage detected