Skip to content

Commit

Permalink
Update name of Confidence to IsConfidence
Browse files Browse the repository at this point in the history
  • Loading branch information
goloop committed Jun 29, 2023
1 parent 28bb39a commit 45e13f5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,17 @@ Here's an explanation of some key parts of this package:

- The Trit type is used to represent a "trinary digit," which can take on three states: False, Unknown, and True.

- Package defineds various methods on the Trit type that allow you to perform operations on trinary digits, including determining if a trinary digit represents False, Unknown, or True, setting the value of a trinary digit based on an integer, normalizing a trinary digit, converting a trinary digit to an integer or a string, and performing logical NOT, AND, OR, XOR, NAND, NOR, and XNOR operations on trinary digits.
- Package defineds various methods on the Trit type that allow you to perform operations on trinary digits, including determining if a trinary digit represents False, Unknown, or True, setting the value of a trinary digit based on an integer, normalizing a trinary digit, converting a trinary digit to an integer or a string.

- The Trit type is defined as an alias for int8, and it can take one of three constants as its value: False, Unknown, or True. False corresponds to any negative number (including -1), Unknown corresponds to 0, and True corresponds to any positive number (including 1).

- There are four methods (Def, DefTrue, DefFalse, and Clean) that check if the value of a Trit is Unknown and change its value based on the method called. For instance, DefTrue will set the Trit to True if its current value is Unknown.
- Provides methods default state (like Default, TrueIfUnknown, FalseIFUnknown etc.,) that check if the value of a Trit is Unknown and change its value based on the method called. For instance, TrueIfUnknown will set the Trit to True if its current value is Unknown.

- There are three methods (IsFalse, IsUnknown, and IsTrue) that check the state of a Trit and return a boolean indicating if the Trit is in the corresponding state.
- There are some methods (like IsFalse, IsUnknown, IsTrue, IsConfidence etc.,) that check the state of a Trit and return a boolean indicating if the Trit is in the corresponding state.

- These methods perform various operations like assigning a value to a Trit (Set), returning the normalized value of a Trit (Val), normalizing the Trit in place (Norm), getting the integer representation of the Trit (Int), and getting the string representation of the Trit (String).
- Some methods perform various operations like assigning a value to a Trit (Set), returning the normalized value of a Trit (Val), normalizing the Trit in place (Norm), getting the integer representation of the Trit (Int), and getting the string representation of the Trit (String).

- There are several methods for performing logic operations on Trit values including Not, And, Or, Xor, Nand, and Nor. These methods implement trinary logic versions of their respective boolean logic operations.
- There are several methods for performing logic operations on Trit values including Not, And, Or, Xor, Nand, Nor etc. These methods implement trinary logic versions of their respective boolean logic operations.

- The logic operation methods follow truth tables for ternary logic which are defined in the package comment section.

Expand Down
8 changes: 4 additions & 4 deletions fn.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,17 +333,17 @@ func Neq[T, U Logicable](a T, b U) Trit {
return ta.Neq(tb)
}

// Confidence returns boolean true if all Trit-Like values has definiteness,
// IsConfidence returns boolean true if all Trit-Like values has definiteness,
// i.e. is either True or False.
//
// Example usage:
//
// a := trit.Confidence(trit.True, trit.False, trit.Unknown)
// a := trit.IsConfidence(trit.True, trit.False, trit.Unknown)
// fmt.Println(a.String()) // Output: False
//
// b := trit.Confidence(trit.True, trit.True, trit.False)
// b := trit.IsConfidence(trit.True, trit.True, trit.False)
// fmt.Println(b.String()) // Output: True
func Confidence[T Logicable](ts ...T) bool {
func IsConfidence[T Logicable](ts ...T) bool {
for _, t := range ts {
trit := logicToTrit(t)
if trit == Unknown {
Expand Down
18 changes: 9 additions & 9 deletions fn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,45 +802,45 @@ func TestNeq(t *testing.T) {
}
}

// TestConfidence tests the Confidence function.
func TestConfidence(t *testing.T) {
// TestIsConfidence tests the IsConfidence function.
func TestIsConfidence(t *testing.T) {
tests := []struct {
name string
in []Trit
out bool
}{
{
name: "Confidence should return true for (True, True, True)",
name: "IsConfidence should return true for (True, True, True)",
in: []Trit{True, True, True},
out: true,
},
{
name: "Confidence should return true for (True, True, False)",
name: "IsConfidence should return true for (True, True, False)",
in: []Trit{True, True, False},
out: true,
},
{
name: "Confidence should return true for (False, False, False)",
name: "IsConfidence should return true for (False, False, False)",
in: []Trit{False, False, False},
out: true,
},
{
name: "Confidence should return false for (False, Unknown, True)",
name: "IsConfidence should return false for (False, Unknown, True)",
in: []Trit{False, Unknown, True},
out: false,
},
{
name: "Confidence should return false for (Unknown, Unknown)",
name: "IsConfidence should return false for (Unknown, Unknown)",
in: []Trit{Unknown, Unknown},
out: false,
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
result := Confidence(test.in...)
result := IsConfidence(test.in...)
if result != test.out {
t.Errorf("Confidence did not return %v for %v",
t.Errorf("IsConfidence did not return %v for %v",
test.out, test.in)
}
})
Expand Down

0 comments on commit 45e13f5

Please sign in to comment.