Last active
October 11, 2022 20:38
-
-
Save eelstork/68ddb645f852894787ab06694c577bb0 to your computer and use it in GitHub Desktop.
BT via ternary logic in C#
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
public readonly struct status{ | |
readonly int ω; | |
public static readonly status done = new status( +1 ), fail = new status( -1 ), cont = new status( 0 ); | |
public bool failing => ω == -1; | |
public bool running => ω == 0; | |
public bool complete => ω == +1; | |
// Sequence/Selector | |
public static status operator & (status x, status y) => y; | |
public static status operator | (status x, status y) => y; | |
public static bool operator true (status s) => s.ω != -1; | |
public static bool operator false (status s) => s.ω != +1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment