home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / scheme / 2022 < prev    next >
Encoding:
Text File  |  1992-08-13  |  2.8 KB  |  94 lines

  1. Newsgroups: comp.lang.scheme
  2. Path: sparky!uunet!gatech!bloom-beacon!INTERNET!dont-send-mail-to-path-lines
  3. From: vanMeule@cup.portal.COM
  4. Subject: going back to church
  5. Message-ID: <9208130615.1.11214@cup.portal.com>
  6. Sender: daemon@athena.mit.edu (Mr Background)
  7. Organization: The Internet
  8. Date: Thu, 13 Aug 1992 13:15:15 GMT
  9. Lines: 83
  10.  
  11. (Just call me Andre van Winkle...)  Just got caught up on my mail.
  12.  
  13. On the church numeral question, though it has been answered I 
  14. wanted to interject my own vantage point.
  15.  
  16. First, I would reference my two articles on church math in May 
  17. and June MacTutor 1991.  I want to write another article on them
  18. but I have to be careful as I'm pushing the limits for theoretical
  19. type stuff as it is, and I can't seem to find another publisher for
  20. my churchy stuff...
  21.  
  22. To summarize some of my thoughts:
  23. 1)  The only interesting thing you can do with a church numeral
  24. is to unravel it.  If you unravel with 1+ and 0 you convert to
  25. regular numbers.  If you unravel with other church numerals you
  26. get church math (that's how mul and expt is defined).  Church
  27. numerals are like pre-initialized for loops.  
  28. 2) You don't want to unravel with 1+ and 0 in the church math 
  29. functions themselves--you want to be lazy and general and do
  30. that only as needs be (since you might unravel with many other
  31. things in other situations).  
  32. 3)  There is a way to define mul in more easy to understand 
  33. terms.  THe classical way is powerful fireworks, but a mind
  34. bender.  You can define it in terms of add, just as in 
  35. primitive recursion.  I will show how to do this by uploading
  36. a pre-prepared file...I hope this works--I'm on a paid system
  37. that is quite crude.  BTW, my phone is (818) 884-9610 should 
  38. anyone want to discuss further off-line.  (Sorry for the length
  39. of this!)...
  40. ;
  41. (define project-2nd-of-2
  42.   (lambda (x)
  43.     identity))
  44. ;
  45. (define identity ; project-1st-of-1
  46.   (lambda (x) x))
  47. ;
  48. (define unravel
  49.   (lambda (n)
  50.     (lambda (f)
  51.       (lambda (x)
  52.         ((n f) x)))))
  53. ;
  54. (define church->number ; dechurchify-numeral
  55.   (lambda (church-numeral)
  56.     (((unravel church-numeral) 1+) 0)))
  57. ;
  58. (define number->church ; make-church-numeral
  59.   (lambda (n)
  60.     (if (zero? n)
  61.         com-zero
  62.         (com-succ 
  63.          (number->church (- n 1))))))
  64. ;
  65. (define com-zero ; The Mother of all Church numerals.
  66.   project-2nd-of-2)
  67. ;
  68. (define com-succ
  69.   (lambda (n)
  70.     (lambda (f)
  71.       (lambda (x)
  72.         (f (((unravel n) f) x))))))
  73. ;
  74. (define lay-add 
  75.   (lambda (addend)
  76.     (lambda (augend)
  77.       (((unravel augend) com-succ) addend))))
  78. ;
  79. (define lay-mul
  80.   (lambda (multiplicand)
  81.     (lambda (multiplier)
  82.       (((unravel multiplicand) 
  83.         (lay-add multiplier))
  84.        com-zero))))
  85. ;
  86. (define foo
  87.   ((lay-mul (number->church 5))
  88.    (number->church 3)))
  89. ;
  90. (church->number foo)
  91.  
  92. ;BTW I ran this code in MacScheme, so I KNOW it works!!!! At 
  93. ;least it did before I sent it!!!!
  94.