Skip to content

Instantly share code, notes, and snippets.

@eelstork
Last active October 11, 2022 20:38
Show Gist options
  • Save eelstork/68ddb645f852894787ab06694c577bb0 to your computer and use it in GitHub Desktop.
Save eelstork/68ddb645f852894787ab06694c577bb0 to your computer and use it in GitHub Desktop.
BT via ternary logic in C#
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