考虑这个 Haskell 代码,它通过将布尔表达式混搭到 NAND(如在电路板上)来简化布尔表达式,然后重构它: https ://gist.github.com/kvanberendonck/5862432/c3c059138701fe127e556a2ca3696fe11c091252
使用 GHC 7.4.2 编译时,我在 Windows 系统上得到以下输出:
Before:
And (Or (Not (Input 1)) (And (And (Input 2) (Input 1)) (Input 3))) (Not (Or (Inp
ut 1) (And (Input 2) (Input 4))))
Mash:
Nand (Nand (Nand (Nand (Nand (Input 1) (Input 1)) (Nand (Input 1) (Input 1))) (N
and (Nand (Nand (Nand (Nand (Input 2) (Input 1)) (Nand (Input 2) (Input 1))) (In
put 3)) (Nand (Nand (Nand (Input 2) (Input 1)) (Nand (Input 2) (Input 1))) (Inpu
t 3))) (Nand (Nand (Nand (Nand (Input 2) (Input 1)) (Nand (Input 2) (Input 1)))
(Input 3)) (Nand (Nand (Nand (Input 2) (Input 1)) (Nand (Input 2) (Input 1))) (I
nput 3))))) (Nand (Nand (Nand (Input 1) (Input 1)) (Nand (Nand (Nand (Input 2) (
Input 4)) (Nand (Input 2) (Input 4))) (Nand (Nand (Input 2) (Input 4)) (Nand (In
put 2) (Input 4))))) (Nand (Nand (Input 1) (Input 1)) (Nand (Nand (Nand (Input 2
) (Input 4)) (Nand (Input 2) (Input 4))) (Nand (Nand (Input 2) (Input 4)) (Nand
(Input 2) (Input 4))))))) (Nand (Nand (Nand (Nand (Input 1) (Input 1)) (Nand (In
put 1) (Input 1))) (Nand (Nand (Nand (Nand (Nand (Input 2) (Input 1)) (Nand (Inp
ut 2) (Input 1))) (Input 3)) (Nand (Nand (Nand (Input 2) (Input 1)) (Nand (Input
2) (Input 1))) (Input 3))) (Nand (Nand (Nand (Nand (Input 2) (Input 1)) (Nand (
Input 2) (Input 1))) (Input 3)) (Nand (Nand (Nand (Input 2) (Input 1)) (Nand (In
put 2) (Input 1))) (Input 3))))) (Nand (Nand (Nand (Input 1) (Input 1)) (Nand (N
and (Nand (Input 2) (Input 4)) (Nand (Input 2) (Input 4))) (Nand (Nand (Input 2)
(Input 4)) (Nand (Input 2) (Input 4))))) (Nand (Nand (Input 1) (Input 1)) (Nand
(Nand (Nand (Input 2) (Input 4)) (Nand (Input 2) (Input 4))) (Nand (Nand (Input
2) (Input 4)) (Nand (Input 2) (Input 4)))))))
After:
simpl.exe:
从我的角度来看,After: simpl.exe
这没有任何意义。这似乎是程序调用。我不明白发生了什么。请指教。