Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,56 @@
unit TrinaryLogic;
interface
//Define our own type for ternary logic.
//This is actually still a Boolean, but the compiler will use distinct RTTI information.
type
TriBool = type Boolean;
const
TTrue:TriBool = True;
TFalse:TriBool = False;
TMaybe:TriBool = TriBool(2);
function TVL_not(Value: TriBool): TriBool;
function TVL_and(A, B: TriBool): TriBool;
function TVL_or(A, B: TriBool): TriBool;
function TVL_xor(A, B: TriBool): TriBool;
function TVL_eq(A, B: TriBool): TriBool;
implementation
Uses
SysUtils;
function TVL_not(Value: TriBool): TriBool;
begin
if Value = True Then
Result := TFalse
else If Value = False Then
Result := TTrue
else
Result := Value;
end;
function TVL_and(A, B: TriBool): TriBool;
begin
Result := TriBool(Iff(Integer(A * B) > 1, Integer(TMaybe), A * B));
end;
function TVL_or(A, B: TriBool): TriBool;
begin
Result := TVL_not(TVL_and(TVL_not(A), TVL_not(B)));
end;
function TVL_xor(A, B: TriBool): TriBool;
begin
Result := TVL_and(TVL_or(A, B), TVL_not(TVL_or(A, B)));
end;
function TVL_eq(A, B: TriBool): TriBool;
begin
Result := TVL_not(TVL_xor(A, B));
end;
end.

View file

@ -0,0 +1 @@
type TriBool = (tbFalse, tbMaybe, tbTrue);

View file

@ -0,0 +1,22 @@
const
tvl_not: array[TriBool] = (tbTrue, tbMaybe, tbFalse);
tvl_and: array[TriBool, TriBool] = (
(tbFalse, tbFalse, tbFalse),
(tbFalse, tbMaybe, tbMaybe),
(tbFalse, tbMaybe, tbTrue),
);
tvl_or: array[TriBool, TriBool] = (
(tbFalse, tbMaybe, tbTrue),
(tbMaybe, tbMaybe, tbTrue),
(tbTrue, tbTrue, tbTrue),
);
tvl_xor: array[TriBool, TriBool] = (
(tbFalse, tbMaybe, tbTrue),
(tbMaybe, tbMaybe, tbMaybe),
(tbTrue, tbMaybe, tbFalse),
);
tvl_eq: array[TriBool, TriBool] = (
(tbTrue, tbMaybe, tbFalse),
(tbMaybe, tbMaybe, tbMaybe),
(tbFalse, tbMaybe, tbTrue),
);

View file

@ -0,0 +1 @@
Result := tvl_and[A, B];