carlton@husc2.HARVARD.EDU (david carlton) (06/06/90)
Here are a couple of neat little Scheme things I've come across or come up with here at school. I hope this is not out of line for the newsgroup, which seems to be pretty serious. ;; #1 ;; By Carl Muckenhoupt ;; Put in more lambdas if you want. (define list (lambda lambda lambda)) ;; #2 Self-rep ;; This expression prints itself out. ((lambda (s) `(,s ',s)) '(lambda (s) `(,s ',s))) ;; #2b Self-rep II ;; So does this one. Which part of this one can be changed to ;; any old quoted expression? ((lambda (s t) `(,s ',s ',t)) '(lambda (s t) `(,s ',s ',t)) '(lambda (s t) `(,s ',s ',t))) ;; #3 Self-rep III (two-stage) ((lambda (s t) `(,s ',s ,(not t))) '(lambda (s t) `(,s ',s ,(not t))) t) ;; #3b Self-rep IV (n-stage) ((lambda (s t) `(,s ',s ,(mod (1+ t) n))) '(lambda (s t) `(,s ',s ,(mod (1+ t) n))) 0) ;; #4 call/cc nightmare (true by definition?) (define I (lambda (x) x)) ((call/cc call/cc) I) ;; What does this return, and why? ;; How about ((call/cc call/cc) (call/cc call/cc)) If you have any tidbits like these, or improvements or variations on these, I would *love* to see them, and would be grateful if you would send them to me. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Lars Huttar huttar@occs.cs.oberlin.edu Oberlin College CS ;; US mail: 206 Merribrook Trail Duncanville, TX 75116