Skip to content

Commit

Permalink
refactor(snake): simplify snake_contains fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeromos Kovács committed Dec 1, 2024
1 parent 9720e76 commit 7c96ff6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/snake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ struct App {
}

bool snake_contains(const Coord& coord, const unsigned& skip = 0) {
return std::find_if(std::begin(this->snake) + skip, this->snake.end(),
[&](const Coord& item) { return item == coord; }) != this->snake.end();
return std::any_of(this->snake.begin() + skip, this->snake.end(),
[&](const Coord& item) { return item == coord; });
}

void eat_apple() {
Expand Down

0 comments on commit 7c96ff6

Please sign in to comment.