gitee.com/quant1x/num@v0.3.2/internal/functions/boolean.go (about) 1 package functions 2 3 import "gitee.com/quant1x/num/internal/constraints" 4 5 func Not_Go(x []bool) { 6 for i := 0; i < len(x); i++ { 7 x[i] = !x[i] 8 } 9 } 10 11 func And_Go(x, y []bool) { 12 for i := 0; i < len(x); i++ { 13 x[i] = x[i] && y[i] 14 } 15 } 16 17 func Or_Go(x, y []bool) { 18 for i := 0; i < len(x); i++ { 19 x[i] = x[i] || y[i] 20 } 21 } 22 23 func Xor_Go(x, y []bool) { 24 for i := 0; i < len(x); i++ { 25 x[i] = x[i] != y[i] 26 } 27 } 28 29 func Select_Go[T constraints.Float](dst, x []T, y []bool) []T { 30 dst = dst[:0] 31 for i := 0; i < len(y); i++ { 32 if y[i] { 33 dst = append(dst, x[i]) 34 } 35 } 36 return dst 37 } 38 39 func All_Go(x []bool) bool { 40 for i := 0; i < len(x); i++ { 41 if !x[i] { 42 return false 43 } 44 } 45 return true 46 } 47 48 func Any_Go(x []bool) bool { 49 for i := 0; i < len(x); i++ { 50 if x[i] { 51 return true 52 } 53 } 54 return false 55 } 56 57 func None_Go(x []bool) bool { 58 for i := 0; i < len(x); i++ { 59 if x[i] { 60 return false 61 } 62 } 63 return true 64 } 65 66 func Count_Go(x []bool) int { 67 cnt := 0 68 for i := 0; i < len(x); i++ { 69 if x[i] { 70 cnt += 1 71 } 72 } 73 return cnt 74 }