++++++++[>+++++++++<-]>.<+++++[>++++++<-]>-.+++++++..+++.< ++++++++[>>++++<<-]>>.<<++++[>------<-]>.<++++[>++++++<-]> .+++.------.--------.>+. End of Program
...thats hello world (source code found here). Scheme isn't that bad.
But Perl. Thats bad. Look what you have to do to write a Perl program to add one and one to make two!
((Y R) ONE ONE) (((%x.R (x x))(%x.R (x x))) ONE ONE) ((R (%x.(R (x x)) %x.(R (x x)))) ONE ONE)
((%m.(%n.IF (IS_ZERO m) n ((%x.(R (x x)) %x.(R (x x))) (PRED m) (SUCC n)))) ONE ONE)
++++++++[>>++++<<-]>>.<<++++[>------<-]>.<++++[>++++++<-]>
.+++.------.--------.>+.
End of Program
...thats hello world (source code found here). Scheme isn't that bad.
But Perl. Thats bad. Look what you have to do to write a Perl program to add one and one to make two!
((Y R) ONE ONE)
(((%x.R (x x))(%x.R (x x))) ONE ONE)
((R (%x.(R (x x)) %x.(R (x x)))) ONE ONE)
((%m.(%n.IF (IS_ZERO m) n ((%x.(R (x x)) %x.(R (x x))) (PRED m) (SUCC n)))) ONE ONE)
(IF (IS_ZERO ONE) ONE ((%x.(R (x x)) %x.(R (x x))) (PRED ONE) (SUCC ONE)))
(IF ((%n.(FIRST n)) (SUCC ZERO)) ONE ((%x.(R (x x)) %x.(R (x x))) (PRED ONE) (SUCC ONE)))
(IF (FIRST (SUCC ZERO)) ONE ((%x.(R (x x)) %x.(R (x x))) (PRED ONE) (SUCC ONE)))
(IF (FIRST (PAIR (FALSE ZERO))) ONE ((%x.(R (x x)) %x.(R (x x))) (PRED ONE) (SUCC ONE)))
(IF FALSE ONE ((%x.(R (x x)) %x.(R (x x))) (PRED ONE) (SUCC ONE)))
((%x.(R (x x)) %x.(R (x x))) (PRED ONE) (SUCC ONE))
((%x.(R (x x)) %x.(R (x x))) (SECOND (PAIR FALSE ZERO)) TWO)
((%x.(R (x x)) %x.(R (x x))) ZERO TWO)
(R ((%x.(R (x x)) %x.(R (x x)))) ZERO TWO)
((%m.(%n.IF (IS_ZERO m) n ((%x.(R (x x)) %x.(R (x x))) (PRED m) (SUCC n)))) ZERO TWO)
(IF (IS_ZERO ZERO) TWO ((%x.(R (x x)) %x.(R (x x))) (PRED ZERO) (SUCC TWO)))
(IF (FIRST (PAIR TRUE TRUE)) TWO ((%x.(R (x x)) %x.(R (x x))) (PRED ZERO) (SUCC TWO)))
(IF TRUE TWO ((%x.(R (x x)) %x.(R (x x))) (PRED ZERO) (SUCC TWO)))
TWO
...of course, thats using Lambda calculus to do it. Tongue squarely in cheek on this one. The Perl listing is from here.
Reply
Leave a comment