On Scheme:

Mar 12, 2006 20:26

I prefer Brainfuck ( Read more... )

computers, geekery, gimp, rants

Leave a comment

Brainfuck? steevr March 12 2006, 19:59:12 UTC
++++++++[>+++++++++<-]>.<+++++[>++++++<-]>-.+++++++..+++.<
++++++++[>>++++<<-]>>.<<++++[>------<-]>.<++++[>++++++<-]>
.+++.------.--------.>+.
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

Up