Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我不用996,因此花了点时间写了几行代码 希望能帮助到你们 #172

Open
restxx opened this issue Jan 23, 2022 · 2 comments

Comments

@restxx
Copy link

restxx commented Jan 23, 2022

coding=utf-8

def go_Not(a):
print("if !(%s) && !(%s){\n"
"}" % (a, a))

def go_And(a, b):
# Pa(a, a)
Pa = "!({A}) && !({A}) ".format({"A": a, "B": b})
# Pb(b, b)
Pb = "!({B}) && !({B}) ".format(
{"A": a, "B": b})
# P(Pa, Pb)
""
print("if !(%s) && !(%s){\n"
"}" % (Pa, Pb))

def go_Or(a, b):
Pab = "!({A}) && !({B}) ".format(**{"A": a, "B": b})
print("if !(%s) && !(%s){\n"
"}" % (Pab, Pab))

if name == "main":
go_Not("a == b")
go_And("a == 1", "b == 2")
go_Or("a != 1", "b == 2")

pass
@restxx
Copy link
Author

restxx commented Jan 23, 2022

这几行代码是用来将go代码的逻辑运算进行负优化的,思路是用 not not and 来负优化常用的逻辑运算,试想一下git里全是这种东西,再来个大神上AST 开启三级负优化(能力有限只达到了负一级),公司想用继续用你的代码就是个笑话

@JEesse83
Copy link

利害。但我担心code review过不去。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants