1 Star 0 Fork 2

王布衣 / num

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
boolean.go 1.00 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2024-02-12 09:23 . 调整package
package functions
import "gitee.com/quant1x/num/internal/constraints"
func Not_Go(x []bool) {
for i := 0; i < len(x); i++ {
x[i] = !x[i]
}
}
func And_Go(x, y []bool) {
for i := 0; i < len(x); i++ {
x[i] = x[i] && y[i]
}
}
func Or_Go(x, y []bool) {
for i := 0; i < len(x); i++ {
x[i] = x[i] || y[i]
}
}
func Xor_Go(x, y []bool) {
for i := 0; i < len(x); i++ {
x[i] = x[i] != y[i]
}
}
func Select_Go[T constraints.Float](dst, x []T, y []bool) []T {
dst = dst[:0]
for i := 0; i < len(y); i++ {
if y[i] {
dst = append(dst, x[i])
}
}
return dst
}
func All_Go(x []bool) bool {
for i := 0; i < len(x); i++ {
if !x[i] {
return false
}
}
return true
}
func Any_Go(x []bool) bool {
for i := 0; i < len(x); i++ {
if x[i] {
return true
}
}
return false
}
func None_Go(x []bool) bool {
for i := 0; i < len(x); i++ {
if x[i] {
return false
}
}
return true
}
func Count_Go(x []bool) int {
cnt := 0
for i := 0; i < len(x); i++ {
if x[i] {
cnt += 1
}
}
return cnt
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/quant1x/num.git
git@gitee.com:quant1x/num.git
quant1x
num
num
v0.3.2

搜索帮助

344bd9b3 5694891 D2dac590 5694891