Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!husc6!husc2!carlton From: carlton@husc2.HARVARD.EDU (david carlton) Newsgroups: comp.lang.scheme Subject: frivolous Scheme things (Fun Only posting) Message-ID: <3135@husc6.harvard.edu> Date: 5 Jun 90 18:10:07 GMT Sender: news@husc6.harvard.edu Reply-To: huttar@occs.cs.oberlin.edu (Lars Huttar) Distribution: na Organization: Oberlin College CS Oberlin, OH Lines: 46 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