boolean

package module
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 2 Imported by: 0

README

Boolean data type has two possible truth values to represent logic.
📦 GoDev, 📰 GoDoc, 📘 Wiki.

Here is my implementation of digital logic gates in software. That includes the basic gates Not, And, Or, Xor; their complements Nand, Nor, Xnor; and 2 propositional logic (taught in discrete mathematics) gates Imply, Eq; and their complements Nimply, Neq. There is also a multiplexer, called Select, and a true counter, called Count. Count can help you make custom gates, such as an alternate concept of xnor which returns true only if all inputs are the same (standard Xnor returns true if even inputs are true). All of them can handle upto 8 inputs.

Parse is influenced by "boolean" package, and is quite good at translating string to boolean. It can also handle double negatives, eg. not inactive. You know the And of 2-inputs, but what of 1-input? What of 0? And what of the other gates? I answer them here.

Stability: Experimental.


import (
  boolean "github.com/golangf/extra-boolean"
)

boolean.Parse("1")
boolean.Parse("truthy")
boolean.Parse("not off")
// true

boolean.Parse("not true")
boolean.Parse("inactive")
boolean.Parse("disabled")
// false

boolean.Imply(true, false)
// false

boolean.Eq(false, false)
// true

boolean.Xor3(true, true, true)
// true

boolean.Select3(1, true, false, true)
// false                   ^

boolean.Count3(true, false, true)
// 2            ^            ^


Index

Name Action
Parse Converts string to boolean.
Not Checks if value is false.
And Checks if all values are true.
Or Checks if any value is true.
Xor Checks if odd no. of values are true.
Nand Checks if any value is false.
Nor Checks if all values are false.
Xnor Checks if even no. of values are true.
Eq Checks if antecedent ⇔ consequent (a ⇔ b).
Neq Checks if antecedent ⇎ consequent (a ⇎ b).
Imply Checks if antecedent ⇒ consequent (a ⇒ b).
Nimply Checks if antecedent ⇏ consequent (a ⇏ b).
Select Checks if ith value is true.
Count Counts no. of true values.


References



Documentation

Overview

Boolean data type has two possible truth values to represent logic.

📦 Package: https://pkg.go.dev/github.com/golangf/extra-boolean

📘 Wiki: https://github.com/golangf/extra-boolean/wiki.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func And added in v0.1.0

func And(a bool, b bool) bool

Checks if all values are true.

// And[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

And(true, true)               == true
And(true, false)              == false
And4(true, true, true, true)  == true
And4(true, false, true, true) == false
Example
fmt.Println(And(true, true))               // true
fmt.Println(And(true, false))              // false
fmt.Println(And4(true, true, true, true))  // true
fmt.Println(And4(true, false, true, true)) // false
Output:

true
false
true
false

func And0 added in v0.1.0

func And0() bool

Checks if all values are true.

// And[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

And(true, true)               == true
And(true, false)              == false
And4(true, true, true, true)  == true
And4(true, false, true, true) == false

func And1 added in v0.1.0

func And1(a bool) bool

Checks if all values are true.

// And[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

And(true, true)               == true
And(true, false)              == false
And4(true, true, true, true)  == true
And4(true, false, true, true) == false

func And2 added in v0.1.0

func And2(a bool, b bool) bool

Checks if all values are true.

// And[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

And(true, true)               == true
And(true, false)              == false
And4(true, true, true, true)  == true
And4(true, false, true, true) == false

func And3 added in v0.1.0

func And3(a bool, b bool, c bool) bool

Checks if all values are true.

// And[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

And(true, true)               == true
And(true, false)              == false
And4(true, true, true, true)  == true
And4(true, false, true, true) == false

func And4 added in v0.1.0

func And4(a bool, b bool, c bool, d bool) bool

Checks if all values are true.

// And[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

And(true, true)               == true
And(true, false)              == false
And4(true, true, true, true)  == true
And4(true, false, true, true) == false

func And5 added in v0.1.0

func And5(a bool, b bool, c bool, d bool, e bool) bool

Checks if all values are true.

// And[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

And(true, true)               == true
And(true, false)              == false
And4(true, true, true, true)  == true
And4(true, false, true, true) == false

func And6 added in v0.1.0

func And6(a bool, b bool, c bool, d bool, e bool, f bool) bool

Checks if all values are true.

// And[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

And(true, true)               == true
And(true, false)              == false
And4(true, true, true, true)  == true
And4(true, false, true, true) == false

func And7 added in v0.1.0

func And7(a bool, b bool, c bool, d bool, e bool, f bool, g bool) bool

Checks if all values are true.

// And[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

And(true, true)               == true
And(true, false)              == false
And4(true, true, true, true)  == true
And4(true, false, true, true) == false

func And8 added in v0.1.0

func And8(a bool, b bool, c bool, d bool, e bool, f bool, g bool, h bool) bool

Checks if all values are true.

// And[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

And(true, true)               == true
And(true, false)              == false
And4(true, true, true, true)  == true
And4(true, false, true, true) == false

func Count added in v0.1.0

func Count(a bool, b bool) int

Counts no. of true values.

// Count[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Count(true, true)                 == 2
Count(true, false)                == 1
Count4(true, true, true, false)   == 3
Count4(false, true, false, false) == 1
Example
fmt.Println(Count(true, true))                 // 2
fmt.Println(Count(true, false))                // 1
fmt.Println(Count4(true, true, true, false))   // 3
fmt.Println(Count4(false, true, false, false)) // 1
Output:

2
1
3
1

func Count0 added in v0.1.0

func Count0() int

Counts no. of true values.

// Count[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Count(true, true)                 == 2
Count(true, false)                == 1
Count4(true, true, true, false)   == 3
Count4(false, true, false, false) == 1

func Count1 added in v0.1.0

func Count1(a bool) int

Counts no. of true values.

// Count[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Count(true, true)                 == 2
Count(true, false)                == 1
Count4(true, true, true, false)   == 3
Count4(false, true, false, false) == 1

func Count2 added in v0.1.0

func Count2(a bool, b bool) int

Counts no. of true values.

// Count[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Count(true, true)                 == 2
Count(true, false)                == 1
Count4(true, true, true, false)   == 3
Count4(false, true, false, false) == 1

func Count3 added in v0.1.0

func Count3(a bool, b bool, c bool) int

Counts no. of true values.

// Count[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Count(true, true)                 == 2
Count(true, false)                == 1
Count4(true, true, true, false)   == 3
Count4(false, true, false, false) == 1

func Count4 added in v0.1.0

func Count4(a bool, b bool, c bool, d bool) int

Counts no. of true values.

// Count[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Count(true, true)                 == 2
Count(true, false)                == 1
Count4(true, true, true, false)   == 3
Count4(false, true, false, false) == 1

func Count5 added in v0.1.0

func Count5(a bool, b bool, c bool, d bool, e bool) int

Counts no. of true values.

// Count[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Count(true, true)                 == 2
Count(true, false)                == 1
Count4(true, true, true, false)   == 3
Count4(false, true, false, false) == 1

func Count6 added in v0.1.0

func Count6(a bool, b bool, c bool, d bool, e bool, f bool) int

Counts no. of true values.

// Count[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Count(true, true)                 == 2
Count(true, false)                == 1
Count4(true, true, true, false)   == 3
Count4(false, true, false, false) == 1

func Count7 added in v0.1.0

func Count7(a bool, b bool, c bool, d bool, e bool, f bool, g bool) int

Counts no. of true values.

// Count[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Count(true, true)                 == 2
Count(true, false)                == 1
Count4(true, true, true, false)   == 3
Count4(false, true, false, false) == 1

func Count8 added in v0.1.0

func Count8(a bool, b bool, c bool, d bool, e bool, f bool, g bool, h bool) int

Counts no. of true values.

// Count[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Count(true, true)                 == 2
Count(true, false)                == 1
Count4(true, true, true, false)   == 3
Count4(false, true, false, false) == 1

func Eq added in v0.0.3

func Eq(a bool, b bool) bool

Checks if antecedent ⇔ consequent (a ⇔ b).

// Eq(a, b)
// a: antecedent
// b: consequent

Example:

Eq(true, true)   == true
Eq(false, false) == true
Eq(true, false)  == false
Eq(false, true)  == false
Example
fmt.Println(Eq(true, true))   // true
fmt.Println(Eq(false, false)) // true
fmt.Println(Eq(true, false))  // false
fmt.Println(Eq(false, true))  // false
Output:

true
true
false
false

func Eqv added in v0.1.0

func Eqv(a bool, b bool) bool

Checks if antecedent ⇔ consequent (a ⇔ b).

// Eqv(a, b)
// a: antecedent
// b: consequent

Example:

Eqv(true, true)   == true
Eqv(false, false) == true
Eqv(true, false)  == false
Eqv(false, true)  == false
Example
fmt.Println(Eqv(true, true))   // true
fmt.Println(Eqv(false, false)) // true
fmt.Println(Eqv(true, false))  // false
fmt.Println(Eqv(false, true))  // false
Output:

true
true
false
false

func Imp added in v0.1.0

func Imp(a bool, b bool) bool

Checks if antecedent ⇒ consequent (a ⇒ b).

// Imp(a, b)
// a: antecedent
// b: consequent

Example:

Imp(true, true)   == true
Imp(false, true)  == true
Imp(false, false) == true
Imp(true, false)  == false
Example
fmt.Println(Imp(true, true))   // true
fmt.Println(Imp(false, true))  // true
fmt.Println(Imp(false, false)) // true
fmt.Println(Imp(true, false))  // false
Output:

true
true
true
false

func Imply added in v0.0.3

func Imply(a bool, b bool) bool

Checks if antecedent ⇒ consequent (a ⇒ b).

// Imply(a, b)
// a: antecedent
// b: consequent

Example:

Imply(true, true)   == true
Imply(false, true)  == true
Imply(false, false) == true
Imply(true, false)  == false
Example
fmt.Println(Imply(true, true))   // true
fmt.Println(Imply(false, true))  // true
fmt.Println(Imply(false, false)) // true
fmt.Println(Imply(true, false))  // false
Output:

true
true
true
false

func Nand added in v0.1.0

func Nand(a bool, b bool) bool

Checks if any value is false.

// Nand[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nand(true, false)              == true
Nand(true, true)               == false
Nand4(true, true, false, true) == true
Nand4(true, true, true, true)  == false
Example
fmt.Println(Nand(true, false))              // true
fmt.Println(Nand(true, true))               // false
fmt.Println(Nand4(true, true, false, true)) // true
fmt.Println(Nand4(true, true, true, true))  // false
Output:

true
false
true
false

func Nand0 added in v0.1.0

func Nand0() bool

Checks if any value is false.

// Nand[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nand(true, false)              == true
Nand(true, true)               == false
Nand4(true, true, false, true) == true
Nand4(true, true, true, true)  == false

func Nand1 added in v0.1.0

func Nand1(a bool) bool

Checks if any value is false.

// Nand[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nand(true, false)              == true
Nand(true, true)               == false
Nand4(true, true, false, true) == true
Nand4(true, true, true, true)  == false

func Nand2 added in v0.1.0

func Nand2(a bool, b bool) bool

Checks if any value is false.

// Nand[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nand(true, false)              == true
Nand(true, true)               == false
Nand4(true, true, false, true) == true
Nand4(true, true, true, true)  == false

func Nand3 added in v0.1.0

func Nand3(a bool, b bool, c bool) bool

Checks if any value is false.

// Nand[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nand(true, false)              == true
Nand(true, true)               == false
Nand4(true, true, false, true) == true
Nand4(true, true, true, true)  == false

func Nand4 added in v0.1.0

func Nand4(a bool, b bool, c bool, d bool) bool

Checks if any value is false.

// Nand[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nand(true, false)              == true
Nand(true, true)               == false
Nand4(true, true, false, true) == true
Nand4(true, true, true, true)  == false

func Nand5 added in v0.1.0

func Nand5(a bool, b bool, c bool, d bool, e bool) bool

Checks if any value is false.

// Nand[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nand(true, false)              == true
Nand(true, true)               == false
Nand4(true, true, false, true) == true
Nand4(true, true, true, true)  == false

func Nand6 added in v0.1.0

func Nand6(a bool, b bool, c bool, d bool, e bool, f bool) bool

Checks if any value is false.

// Nand[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nand(true, false)              == true
Nand(true, true)               == false
Nand4(true, true, false, true) == true
Nand4(true, true, true, true)  == false

func Nand7 added in v0.1.0

func Nand7(a bool, b bool, c bool, d bool, e bool, f bool, g bool) bool

Checks if any value is false.

// Nand[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nand(true, false)              == true
Nand(true, true)               == false
Nand4(true, true, false, true) == true
Nand4(true, true, true, true)  == false

func Nand8 added in v0.1.0

func Nand8(a bool, b bool, c bool, d bool, e bool, f bool, g bool, h bool) bool

Checks if any value is false.

// Nand[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nand(true, false)              == true
Nand(true, true)               == false
Nand4(true, true, false, true) == true
Nand4(true, true, true, true)  == false

func Neq added in v0.0.3

func Neq(a bool, b bool) bool

Checks if antecedent ⇎ consequent (a ⇎ b).

// Neq(a, b)
// a: antecedent
// b: consequent

Example:

Neq(true, false)  == true
Neq(false, true)  == true
Neq(true, true)   == false
Neq(false, false) == false
Example
fmt.Println(Neq(true, false))  // true
fmt.Println(Neq(false, true))  // true
fmt.Println(Neq(true, true))   // false
fmt.Println(Neq(false, false)) // false
Output:

true
true
false
false

func Nimply added in v0.0.3

func Nimply(a bool, b bool) bool

Checks if antecedent ⇏ consequent (a ⇏ b).

// Nimply(a, b)
// a: antecedent
// b: consequent

Example:

Nimply(true, false)  == true
Nimply(true, true)   == false
Nimply(false, true)  == false
Nimply(false, false) == false
Example
fmt.Println(Nimply(true, false))  // true
fmt.Println(Nimply(true, true))   // false
fmt.Println(Nimply(false, true))  // false
fmt.Println(Nimply(false, false)) // false
Output:

true
false
false
false

func Nor added in v0.1.0

func Nor(a bool, b bool) bool

Checks if all values are false.

// Nor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nor(false, false)                == true
Nor(true, false)                 == false
Nor4(false, false, false, false) == true
Nor4(false, false, true, false)  == false
Example
fmt.Println(Nor(false, false))                // true
fmt.Println(Nor(true, false))                 // false
fmt.Println(Nor4(false, false, false, false)) // true
fmt.Println(Nor4(false, false, true, false))  // false
Output:

true
false
true
false

func Nor0 added in v0.1.0

func Nor0() bool

Checks if all values are false.

// Nor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nor(false, false)                == true
Nor(true, false)                 == false
Nor4(false, false, false, false) == true
Nor4(false, false, true, false)  == false

func Nor1 added in v0.1.0

func Nor1(a bool) bool

Checks if all values are false.

// Nor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nor(false, false)                == true
Nor(true, false)                 == false
Nor4(false, false, false, false) == true
Nor4(false, false, true, false)  == false

func Nor2 added in v0.1.0

func Nor2(a bool, b bool) bool

Checks if all values are false.

// Nor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nor(false, false)                == true
Nor(true, false)                 == false
Nor4(false, false, false, false) == true
Nor4(false, false, true, false)  == false

func Nor3 added in v0.1.0

func Nor3(a bool, b bool, c bool) bool

Checks if all values are false.

// Nor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nor(false, false)                == true
Nor(true, false)                 == false
Nor4(false, false, false, false) == true
Nor4(false, false, true, false)  == false

func Nor4 added in v0.1.0

func Nor4(a bool, b bool, c bool, d bool) bool

Checks if all values are false.

// Nor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nor(false, false)                == true
Nor(true, false)                 == false
Nor4(false, false, false, false) == true
Nor4(false, false, true, false)  == false

func Nor5 added in v0.1.0

func Nor5(a bool, b bool, c bool, d bool, e bool) bool

Checks if all values are false.

// Nor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nor(false, false)                == true
Nor(true, false)                 == false
Nor4(false, false, false, false) == true
Nor4(false, false, true, false)  == false

func Nor6 added in v0.1.0

func Nor6(a bool, b bool, c bool, d bool, e bool, f bool) bool

Checks if all values are false.

// Nor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nor(false, false)                == true
Nor(true, false)                 == false
Nor4(false, false, false, false) == true
Nor4(false, false, true, false)  == false

func Nor7 added in v0.1.0

func Nor7(a bool, b bool, c bool, d bool, e bool, f bool, g bool) bool

Checks if all values are false.

// Nor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nor(false, false)                == true
Nor(true, false)                 == false
Nor4(false, false, false, false) == true
Nor4(false, false, true, false)  == false

func Nor8 added in v0.1.0

func Nor8(a bool, b bool, c bool, d bool, e bool, f bool, g bool, h bool) bool

Checks if all values are false.

// Nor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Nor(false, false)                == true
Nor(true, false)                 == false
Nor4(false, false, false, false) == true
Nor4(false, false, true, false)  == false

func Not added in v0.0.3

func Not(a bool) bool

Checks if value is false.

// Not(a, b)
// a: a boolean

Example:

Not(false) == true
Not(true)  == false
Example
fmt.Println(Not(false)) // true
fmt.Println(Not(true))  // false
Output:

true
false

func Or added in v0.1.0

func Or(a bool, b bool) bool

Checks if any value is true.

// Or[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Or(true, false)                 == true
Or(false, false)                == false
Or4(false, true, false, true)   == true
Or4(false, false, false, false) == false
Example
fmt.Println(Or(true, false))                 // true
fmt.Println(Or(false, false))                // false
fmt.Println(Or4(false, true, false, true))   // true
fmt.Println(Or4(false, false, false, false)) // false
Output:

true
false
true
false

func Or0 added in v0.1.0

func Or0() bool

Checks if any value is true.

// Or[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Or(true, false)                 == true
Or(false, false)                == false
Or4(false, true, false, true)   == true
Or4(false, false, false, false) == false

func Or1 added in v0.1.0

func Or1(a bool) bool

Checks if any value is true.

// Or[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Or(true, false)                 == true
Or(false, false)                == false
Or4(false, true, false, true)   == true
Or4(false, false, false, false) == false

func Or2 added in v0.1.0

func Or2(a bool, b bool) bool

Checks if any value is true.

// Or[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Or(true, false)                 == true
Or(false, false)                == false
Or4(false, true, false, true)   == true
Or4(false, false, false, false) == false

func Or3 added in v0.1.0

func Or3(a bool, b bool, c bool) bool

Checks if any value is true.

// Or[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Or(true, false)                 == true
Or(false, false)                == false
Or4(false, true, false, true)   == true
Or4(false, false, false, false) == false

func Or4 added in v0.1.0

func Or4(a bool, b bool, c bool, d bool) bool

Checks if any value is true.

// Or[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Or(true, false)                 == true
Or(false, false)                == false
Or4(false, true, false, true)   == true
Or4(false, false, false, false) == false

func Or5 added in v0.1.0

func Or5(a bool, b bool, c bool, d bool, e bool) bool

Checks if any value is true.

// Or[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Or(true, false)                 == true
Or(false, false)                == false
Or4(false, true, false, true)   == true
Or4(false, false, false, false) == false

func Or6 added in v0.1.0

func Or6(a bool, b bool, c bool, d bool, e bool, f bool) bool

Checks if any value is true.

// Or[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Or(true, false)                 == true
Or(false, false)                == false
Or4(false, true, false, true)   == true
Or4(false, false, false, false) == false

func Or7 added in v0.1.0

func Or7(a bool, b bool, c bool, d bool, e bool, f bool, g bool) bool

Checks if any value is true.

// Or[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Or(true, false)                 == true
Or(false, false)                == false
Or4(false, true, false, true)   == true
Or4(false, false, false, false) == false

func Or8 added in v0.1.0

func Or8(a bool, b bool, c bool, d bool, e bool, f bool, g bool, h bool) bool

Checks if any value is true.

// Or[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Or(true, false)                 == true
Or(false, false)                == false
Or4(false, true, false, true)   == true
Or4(false, false, false, false) == false

func Parse added in v0.0.1

func Parse(s string) bool

Converts string to boolean.

// Parse(s)
// s: a string

Example:

Parse("1")            == true
Parse("truthy")       == true
Parse("Not Off")      == true
Parse("Not Inactive") == true
Parse("cold")         == false
Parse("inactive")     == false
Parse("Negative Yes") == false
Parse("Negative Aye") == false
Example
fmt.Println(Parse("1"))            // true
fmt.Println(Parse("truthy"))       // true
fmt.Println(Parse("Not Off"))      // true
fmt.Println(Parse("Not Inactive")) // true
fmt.Println(Parse("cold"))         // false
fmt.Println(Parse("inactive"))     // false
fmt.Println(Parse("Negative Yes")) // false
fmt.Println(Parse("Negative Aye")) // false
Output:

true
true
true
true
false
false
false
false

func Select added in v0.1.0

func Select(i int, a bool, b bool) bool

Checks if ith value is true.

// Select[n](i, a, b, ...)
// i: index
// a: 1st boolean
// b: 2nd boolean

Example:

Select(0, true, false)               == true
Select(1, true, false)               == false
Select4(1, true, true, false, false) == true
Select4(2, true, true, false, false) == false
Example
fmt.Println(Select(0, true, false))               // true
fmt.Println(Select(1, true, false))               // false
fmt.Println(Select4(1, true, true, false, false)) // true
fmt.Println(Select4(2, true, true, false, false)) // false
Output:

true
false
true
false

func Select0 added in v0.1.0

func Select0(i int) bool

Checks if ith value is true.

// Select[n](i, a, b, ...)
// i: index
// a: 1st boolean
// b: 2nd boolean

Example:

Select(0, true, false)               == true
Select(1, true, false)               == false
Select4(1, true, true, false, false) == true
Select4(2, true, true, false, false) == false

func Select1 added in v0.1.0

func Select1(i int, a bool) bool

Checks if ith value is true.

// Select[n](i, a, b, ...)
// i: index
// a: 1st boolean
// b: 2nd boolean

Example:

Select(0, true, false)               == true
Select(1, true, false)               == false
Select4(1, true, true, false, false) == true
Select4(2, true, true, false, false) == false

func Select2 added in v0.1.0

func Select2(i int, a bool, b bool) bool

Checks if ith value is true.

// Select[n](i, a, b, ...)
// i: index
// a: 1st boolean
// b: 2nd boolean

Example:

Select(0, true, false)               == true
Select(1, true, false)               == false
Select4(1, true, true, false, false) == true
Select4(2, true, true, false, false) == false

func Select3 added in v0.1.0

func Select3(i int, a bool, b bool, c bool) bool

Checks if ith value is true.

// Select[n](i, a, b, ...)
// i: index
// a: 1st boolean
// b: 2nd boolean

Example:

Select(0, true, false)               == true
Select(1, true, false)               == false
Select4(1, true, true, false, false) == true
Select4(2, true, true, false, false) == false

func Select4 added in v0.1.0

func Select4(i int, a bool, b bool, c bool, d bool) bool

Checks if ith value is true.

// Select[n](i, a, b, ...)
// i: index
// a: 1st boolean
// b: 2nd boolean

Example:

Select(0, true, false)               == true
Select(1, true, false)               == false
Select4(1, true, true, false, false) == true
Select4(2, true, true, false, false) == false

func Select5 added in v0.1.0

func Select5(i int, a bool, b bool, c bool, d bool, e bool) bool

Checks if ith value is true.

// Select[n](i, a, b, ...)
// i: index
// a: 1st boolean
// b: 2nd boolean

Example:

Select(0, true, false)               == true
Select(1, true, false)               == false
Select4(1, true, true, false, false) == true
Select4(2, true, true, false, false) == false

func Select6 added in v0.1.0

func Select6(i int, a bool, b bool, c bool, d bool, e bool, f bool) bool

Checks if ith value is true.

// Select[n](i, a, b, ...)
// i: index
// a: 1st boolean
// b: 2nd boolean

Example:

Select(0, true, false)               == true
Select(1, true, false)               == false
Select4(1, true, true, false, false) == true
Select4(2, true, true, false, false) == false

func Select7 added in v0.1.0

func Select7(i int, a bool, b bool, c bool, d bool, e bool, f bool, g bool) bool

Checks if ith value is true.

// Select[n](i, a, b, ...)
// i: index
// a: 1st boolean
// b: 2nd boolean

Example:

Select(0, true, false)               == true
Select(1, true, false)               == false
Select4(1, true, true, false, false) == true
Select4(2, true, true, false, false) == false

func Select8 added in v0.1.0

func Select8(i int, a bool, b bool, c bool, d bool, e bool, f bool, g bool, h bool) bool

Checks if ith value is true.

// Select[n](i, a, b, ...)
// i: index
// a: 1st boolean
// b: 2nd boolean

Example:

Select(0, true, false)               == true
Select(1, true, false)               == false
Select4(1, true, true, false, false) == true
Select4(2, true, true, false, false) == false

func Xnor added in v0.1.0

func Xnor(a bool, b bool) bool

Checks if even no. of values are true.

// Xnor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xnor(true, true)                == true
Xnor(false, true)               == false
Xnor4(true, true, false, false) == true
Xnor4(true, true, true, false)  == false
Example
fmt.Println(Xnor(true, true))                // true
fmt.Println(Xnor(false, true))               // false
fmt.Println(Xnor4(true, true, false, false)) // true
fmt.Println(Xnor4(true, true, true, false))  // false
Output:

true
false
true
false

func Xnor0 added in v0.1.0

func Xnor0() bool

Checks if even no. of values are true.

// Xnor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xnor(true, true)                == true
Xnor(false, true)               == false
Xnor4(true, true, false, false) == true
Xnor4(true, true, true, false)  == false

func Xnor1 added in v0.1.0

func Xnor1(a bool) bool

Checks if even no. of values are true.

// Xnor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xnor(true, true)                == true
Xnor(false, true)               == false
Xnor4(true, true, false, false) == true
Xnor4(true, true, true, false)  == false

func Xnor2 added in v0.1.0

func Xnor2(a bool, b bool) bool

Checks if even no. of values are true.

// Xnor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xnor(true, true)                == true
Xnor(false, true)               == false
Xnor4(true, true, false, false) == true
Xnor4(true, true, true, false)  == false

func Xnor3 added in v0.1.0

func Xnor3(a bool, b bool, c bool) bool

Checks if even no. of values are true.

// Xnor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xnor(true, true)                == true
Xnor(false, true)               == false
Xnor4(true, true, false, false) == true
Xnor4(true, true, true, false)  == false

func Xnor4 added in v0.1.0

func Xnor4(a bool, b bool, c bool, d bool) bool

Checks if even no. of values are true.

// Xnor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xnor(true, true)                == true
Xnor(false, true)               == false
Xnor4(true, true, false, false) == true
Xnor4(true, true, true, false)  == false

func Xnor5 added in v0.1.0

func Xnor5(a bool, b bool, c bool, d bool, e bool) bool

Checks if even no. of values are true.

// Xnor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xnor(true, true)                == true
Xnor(false, true)               == false
Xnor4(true, true, false, false) == true
Xnor4(true, true, true, false)  == false

func Xnor6 added in v0.1.0

func Xnor6(a bool, b bool, c bool, d bool, e bool, f bool) bool

Checks if even no. of values are true.

// Xnor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xnor(true, true)                == true
Xnor(false, true)               == false
Xnor4(true, true, false, false) == true
Xnor4(true, true, true, false)  == false

func Xnor7 added in v0.1.0

func Xnor7(a bool, b bool, c bool, d bool, e bool, f bool, g bool) bool

Checks if even no. of values are true.

// Xnor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xnor(true, true)                == true
Xnor(false, true)               == false
Xnor4(true, true, false, false) == true
Xnor4(true, true, true, false)  == false

func Xnor8 added in v0.1.0

func Xnor8(a bool, b bool, c bool, d bool, e bool, f bool, g bool, h bool) bool

Checks if even no. of values are true.

// Xnor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xnor(true, true)                == true
Xnor(false, true)               == false
Xnor4(true, true, false, false) == true
Xnor4(true, true, true, false)  == false

func Xor added in v0.1.0

func Xor(a bool, b bool) bool

Checks if odd no. of values are true.

// Xor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xor(true, false)              == true
Xor(true, true)               == false
Xor4(true, true, true, false) == true
Xor4(true, true, true, true)  == false
Example
fmt.Println(Xor(true, false))              // true
fmt.Println(Xor(true, true))               // false
fmt.Println(Xor4(true, true, true, false)) // true
fmt.Println(Xor4(true, true, true, true))  // false
Output:

true
false
true
false

func Xor0 added in v0.1.0

func Xor0() bool

Checks if odd no. of values are true.

// Xor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xor(true, false)              == true
Xor(true, true)               == false
Xor4(true, true, true, false) == true
Xor4(true, true, true, true)  == false

func Xor1 added in v0.1.0

func Xor1(a bool) bool

Checks if odd no. of values are true.

// Xor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xor(true, false)              == true
Xor(true, true)               == false
Xor4(true, true, true, false) == true
Xor4(true, true, true, true)  == false

func Xor2 added in v0.1.0

func Xor2(a bool, b bool) bool

Checks if odd no. of values are true.

// Xor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xor(true, false)              == true
Xor(true, true)               == false
Xor4(true, true, true, false) == true
Xor4(true, true, true, true)  == false

func Xor3 added in v0.1.0

func Xor3(a bool, b bool, c bool) bool

Checks if odd no. of values are true.

// Xor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xor(true, false)              == true
Xor(true, true)               == false
Xor4(true, true, true, false) == true
Xor4(true, true, true, true)  == false

func Xor4 added in v0.1.0

func Xor4(a bool, b bool, c bool, d bool) bool

Checks if odd no. of values are true.

// Xor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xor(true, false)              == true
Xor(true, true)               == false
Xor4(true, true, true, false) == true
Xor4(true, true, true, true)  == false

func Xor5 added in v0.1.0

func Xor5(a bool, b bool, c bool, d bool, e bool) bool

Checks if odd no. of values are true.

// Xor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xor(true, false)              == true
Xor(true, true)               == false
Xor4(true, true, true, false) == true
Xor4(true, true, true, true)  == false

func Xor6 added in v0.1.0

func Xor6(a bool, b bool, c bool, d bool, e bool, f bool) bool

Checks if odd no. of values are true.

// Xor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xor(true, false)              == true
Xor(true, true)               == false
Xor4(true, true, true, false) == true
Xor4(true, true, true, true)  == false

func Xor7 added in v0.1.0

func Xor7(a bool, b bool, c bool, d bool, e bool, f bool, g bool) bool

Checks if odd no. of values are true.

// Xor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xor(true, false)              == true
Xor(true, true)               == false
Xor4(true, true, true, false) == true
Xor4(true, true, true, true)  == false

func Xor8 added in v0.1.0

func Xor8(a bool, b bool, c bool, d bool, e bool, f bool, g bool, h bool) bool

Checks if odd no. of values are true.

// Xor[n](a, b, ...)
// a: 1st boolean
// b: 2nd boolean

Example:

Xor(true, false)              == true
Xor(true, true)               == false
Xor4(true, true, true, false) == true
Xor4(true, true, true, true)  == false

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL