Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #35963 > unrolled thread

When Gregorian replaced Julian

Started by"WJ" <w_a_x_man@yahoo.com>
First post2015-01-23 00:19 +0000
Last post2015-01-24 06:32 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.lang.forth


Contents

  When Gregorian replaced Julian "WJ" <w_a_x_man@yahoo.com> - 2015-01-23 00:19 +0000
    Re: When Gregorian replaced Julian Mark Wills <markwills1970@gmail.com> - 2015-01-23 01:57 -0800
    Re: When Gregorian replaced Julian "Rod Pemberton" <buzz@notnotnontnooatno.cmm> - 2015-01-23 20:23 -0500
    Re: When Gregorian replaced Julian "WJ" <w_a_x_man@yahoo.com> - 2015-01-24 06:32 +0000

#35963 — When Gregorian replaced Julian

From"WJ" <w_a_x_man@yahoo.com>
Date2015-01-23 00:19 +0000
SubjectWhen Gregorian replaced Julian
Message-ID<m9s42m$n26$1@dont-email.me>
Using cal, find the month when England adopted the Gregorian
calendar.

In Emacs Lisp:

(catch 'exit
  (dolist (year (number-sequence 1750 1799))
    (princ year)
    (dolist (month (number-sequence 1 12))
      (let* ((cal (shell-command-to-string (format "cal %s %s" month year)))
             (num-days (length (cdr (split-string cal "[^0-9]+" t)))))
        (princ (format " %s" num-days))
        (when (< num-days 28)
          (terpri) (princ cal)
          (throw 'exit 0))))
    (terpri)))

Output:

1750 31 28 31 30 31 30 31 31 30 31 30 31
1751 31 28 31 30 31 30 31 31 30 31 30 31
1752 31 29 31 30 31 30 31 31 19
    September 1752
 S  M Tu  W Th  F  S
       1  2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

Show your Forth code.

[toc] | [next] | [standalone]


#35967

FromMark Wills <markwills1970@gmail.com>
Date2015-01-23 01:57 -0800
Message-ID<d8714cb9-92b0-4804-b200-8aed7a9f365c@googlegroups.com>
In reply to#35963
On Friday, 23 January 2015 00:20:07 UTC, WJ  wrote:
> Using cal, find the month when England adopted the Gregorian
> calendar.
> 
> In Emacs Lisp:
> 
> (catch 'exit
>   (dolist (year (number-sequence 1750 1799))
>     (princ year)
>     (dolist (month (number-sequence 1 12))
>       (let* ((cal (shell-command-to-string (format "cal %s %s" month year)))
>              (num-days (length (cdr (split-string cal "[^0-9]+" t)))))
>         (princ (format " %s" num-days))
>         (when (< num-days 28)
>           (terpri) (princ cal)
>           (throw 'exit 0))))
>     (terpri)))
> 
> Output:
> 
> 1750 31 28 31 30 31 30 31 31 30 31 30 31
> 1751 31 28 31 30 31 30 31 31 30 31 30 31
> 1752 31 29 31 30 31 30 31 31 19
>     September 1752
>  S  M Tu  W Th  F  S
>        1  2 14 15 16
> 17 18 19 20 21 22 23
> 24 25 26 27 28 29 30
> 
> Show your Forth code.

: gregorian ( -- ) cr ." September 1752" cr ;

[toc] | [prev] | [next] | [standalone]


#35983

From"Rod Pemberton" <buzz@notnotnontnooatno.cmm>
Date2015-01-23 20:23 -0500
Message-ID<op.xsx0ssqlv6dtjm@localhost>
In reply to#35963
On Thu, 22 Jan 2015 19:19:34 -0500, WJ <w_a_x_man@yahoo.com> wrote:

> Using cal, find the month when England adopted the Gregorian
> calendar.
>
> In Emacs Lisp:
>
> (catch 'exit
>   (dolist (year (number-sequence 1750 1799))
>     (princ year)
>     (dolist (month (number-sequence 1 12))
>       (let* ((cal (shell-command-to-string (format "cal %s %s" month  
> year)))
>              (num-days (length (cdr (split-string cal "[^0-9]+" t)))))
>         (princ (format " %s" num-days))
>         (when (< num-days 28)
>           (terpri) (princ cal)
>           (throw 'exit 0))))
>     (terpri)))
>
> Output:
>
> 1750 31 28 31 30 31 30 31 31 30 31 30 31
> 1751 31 28 31 30 31 30 31 31 30 31 30 31
> 1752 31 29 31 30 31 30 31 31 19
>     September 1752
>  S  M Tu  W Th  F  S
>        1  2 14 15 16
> 17 18 19 20 21 22 23
> 24 25 26 27 28 29 30
>
> Show your Forth code.

Which "cal" program are you talking about?  Is this for Linux? ...

You really shouldn't assume that a Gregorian calendar program will
stop returning dates simply because there were no Gregorian dates
prior to a certain date or because some country adopted the calendar
on a certain date.  Most Gregorian calendar programs will continue
to return dates far back in time until they overflow their variables.


Rod Pemberton

[toc] | [prev] | [next] | [standalone]


#35989

From"WJ" <w_a_x_man@yahoo.com>
Date2015-01-24 06:32 +0000
Message-ID<m9ve97$ifb$1@dont-email.me>
In reply to#35963
WJ wrote:

> Using cal, find the month when England adopted the Gregorian
> calendar.
> 
> In Emacs Lisp:
> 
> (catch 'exit
>   (dolist (year (number-sequence 1750 1799))
>     (princ year)
>     (dolist (month (number-sequence 1 12))
>       (let* ((cal (shell-command-to-string (format "cal %s %s" month year)))
>              (num-days (length (cdr (split-string cal "[^0-9]+" t)))))
>         (princ (format " %s" num-days))
>         (when (< num-days 28)
>           (terpri) (princ cal)
>           (throw 'exit 0))))
>     (terpri)))
> 
> Output:
> 
> 1750 31 28 31 30 31 30 31 31 30 31 30 31
> 1751 31 28 31 30 31 30 31 31 30 31 30 31
> 1752 31 29 31 30 31 30 31 31 19
>     September 1752
>  S  M Tu  W Th  F  S
>        1  2 14 15 16
> 17 18 19 20 21 22 23
> 24 25 26 27 28 29 30
> 
> Show your Forth code.

Gauche Scheme:

(use srfi-42) ;; first-ec
(use gauche.process)
(use srfi-13) ;; string-tokenize

(first-ec  'I-failed-to-find-it
  (: year 1750 1800)
  (begin (newline) (display year))
  (: month 1 13)
  (:let cal (call-with-input-process
              (format "cal ~a ~a" month year) port->string))
  (:let num-days (length (cdr (string-tokenize cal #[\d]))))
  (begin (format #t " ~s" num-days))
  (if (< num-days 28))
  (print "\n" cal))


1750 31 28 31 30 31 30 31 31 30 31 30 31
1751 31 28 31 30 31 30 31 31 30 31 30 31
1752 31 29 31 30 31 30 31 31 19
    September 1752
 S  M Tu  W Th  F  S
       1  2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.forth


csiph-web