comp.lang.ada
 help / color / mirror / Atom feed
From: andrewg@microlise.co.uk (Andrew Gierth)
Cc: Ken Pizzini <ken@chinook.halcyon.com>
Subject: Re: language wars (results 13 September) last posting
Date: 1996/09/24
Date: 1996-09-24T00:00:00+00:00	[thread overview]
Message-ID: <uf4tkon7xk.fsf@zen.microlise.co.uk> (raw)
In-Reply-To: 51bv60$8d@pheidippides.axion.bt.co.uk


>>>>> "Ken" == Ken Pizzini <ken@chinook.halcyon.com> writes:

 > In article <32414A27.14E@cat.com>, Daniel J. Long <longdj@cat.com> wrote:
 >> Ok, here is my program, written in Smalltalk, to calculate the
 >> distribution
 >> of Friday the 13ths for a 2800 year period from 1996 to 4795.  BTW,
 >> Friday did
 >> turn out to be the most likely 13th.
[code snipped]
 >> 
 >> Result:  Mon  Tues Wed  Thur Fri  Sat  Sun
 >> #(4795 4795 4809 4788 4816 4788 4809)

 Ken> What is the impentation of Date and/or weekdayIndex?  I think
 Ken> this shows that at least one of them has a bug...

Why do you say that?

OK, so my smalltalk is nonexistent, but the code given looks ok, and here
for your delectation is my version in Emacs Lisp, and my results:

(require 'calendar)

(defun day-of-13th (month year) (calendar-day-of-week (list month 13 year)))

(defun d13-one-year (v year)
  (mapcar (lambda (month)
            (let ((day (day-of-13th month year)))
              (aset v day (1+ (aref v day)))))
   '(1 2 3 4 5 6 7 8 9 10 11 12)) 
  v)

(defun d13-range (first count)
  (let ((v (vector 0 0 0 0 0 0 0)) 
	(y first) 
	(lim (+ first count)))
    (while (< y lim)
      (setq v (d13-one-year v y)) 
      (setq y (1+ y))) 
    v))

(d13-range 1996 2800)
[4809 4795 4795 4809 4788 4816 4788]

Note - this code uses 0=Sunday. So, my results agree with Mr. Long's.

Incidentally, for the curious, I first came across this obscure fact in an
exercise in a book (exactly *which* book I forget, but I vaguely recall that
it might have been Richards (?) & Whitby-Strevens (sp?) book on BCPL). The
exercise simply said "Write a program to prove that the 13th falls more
often on Friday than any other day of the week". So I did (but not in BCPL).

-- 
Andrew Gierth (andrewg@microlise.co.uk)

"Ceterum censeo Microsoftam delendam esse" - Alain Knaff in nanam




  parent reply	other threads:[~1996-09-24  0:00 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-13  0:00 language wars (results 13 September) last posting Roy Gardiner
1996-09-13  0:00 ` William Clodius
1996-09-13  0:00   ` Peter Seebach
1996-09-21  0:00     ` Robert Dewar
1996-09-21  0:00     ` Robert Dewar
1996-09-16  0:00   ` Robert Fahey
1996-09-18  0:00 ` Norman H. Cohen
1996-09-18  0:00 ` James Giles
1996-09-18  0:00 ` James Giles
1996-09-18  0:00 ` Luke Chao
1996-09-18  0:00 ` Andrew Gierth
1996-09-19  0:00 ` Andrew Gierth
1996-09-19  0:00 ` Norman H. Cohen
1996-09-19  0:00 ` Daniel J. Long
1996-09-21  0:00   ` Ken Pizzini
1996-09-21  0:00   ` Ken Pizzini
1996-09-24  0:00     ` Art Schwarz
1996-09-26  0:00       ` Ken Pizzini
1996-09-29  0:00         ` Paul Gilmartin
1996-09-26  0:00       ` Matthew D. Healy
1996-09-29  0:00         ` Randy MacDonald
1996-10-03  0:00           ` galina.kasminskaya
1996-10-03  0:00             ` Dave Tholen
1996-09-20  0:00 ` Friday 13th, try it yourself (was Language Wars..) Clinton Pierce
1996-09-21  0:00   ` Russell Mosemann
1996-09-21  0:00   ` Russell Mosemann
1996-09-25  0:00     ` Barrie Walker
1996-09-26  0:00       ` Jim Shapiro
1996-09-25  0:00     ` Ken Pizzini
1996-09-25  0:00       ` Results of my test: Re: Friday 13th, try it yourself Lee Crites
1996-09-25  0:00         ` William Clodius
1996-09-27  0:00         ` Dik T. Winter
     [not found]           ` <52qpqt$1b3l@ilx018.iil.intel.com>
1996-10-02  0:00             ` Dik T. Winter
1996-10-02  0:00             ` Ken Pizzini
1996-09-26  0:00       ` Dr John Stockton
1996-09-26  0:00         ` Lee Crites
1996-09-26  0:00           ` Adam Beneschan
1996-09-27  0:00             ` Glen Clark
1996-09-26  0:00           ` Daan Sandee
1996-09-26  0:00             ` Jeff Drummond
1996-09-30  0:00               ` Ray Dunn
1996-09-26  0:00           ` John Winters
1996-09-27  0:00           ` CHI Research, Inc. 
1996-09-27  0:00             ` Lee Crites
1996-09-28  0:00               ` John Winters
1996-09-30  0:00               ` Adam Beneschan
1996-10-01  0:00             ` Mike McCarty
1996-09-26  0:00         ` Dr John Stockton
     [not found]         ` <199609302101.JAA04610@kauri.vuw.ac.nz>
1996-09-30  0:00           ` Lee Crites
1996-09-23  0:00   ` Friday 13th, try it yourself (was Language Wars..) Matthew D. Healy
1996-09-23  0:00     ` Dik T. Winter
1996-09-25  0:00     ` Paul Gilmartin
1996-09-20  0:00 ` language wars (results 13 September) last posting John Girash
1996-09-20  0:00   ` John Girash
1996-09-22  0:00 ` Friday 13th, try it yourself (was Language Wars..) Dr John Stockton
1996-09-23  0:00 ` Randy MacDonald
1996-09-23  0:00   ` Dik T. Winter
1996-09-25  0:00   ` John Harper
1996-09-25  0:00     ` jupiter
1996-09-23  0:00 ` Dr John Stockton
1996-09-24  0:00 ` Andrew Gierth [this message]
1996-09-24  0:00   ` language wars (results 13 September) last posting Art Schwarz
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox