generated from mazharenko/aoc-agent-template-multipleyears
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d602136
commit c045e7d
Showing
4 changed files
with
35 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// ReSharper disable once CheckNamespace | ||
|
||
namespace aoc.Common.BfsImpl; | ||
|
||
public delegate bool Target<in T>(T state); // ITarget? | ||
|
||
public static class Targets | ||
{ | ||
public static Target<T> Value<T>(T value) | ||
=> state => Equals(value, state); | ||
} | ||
|
||
public class SearchFold<T>(Target<T> target) : IFold<T, Result<T>> | ||
{ | ||
public (Result<T>, TraversalResult) Fold(Result<T> acc, Path<T> path) | ||
{ | ||
var (current, _) = path.PathList; | ||
if (target(current.Item)) | ||
return (new Found<T>(path), TraversalResult.Interrupt); | ||
return (new NotFound<T>(), TraversalResult.Continue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters