Long year: Difference between revisions

→‎{{header|Scheme}}: Add implementation
(→‎{{header|Common Lisp}}: Add implementation.)
(→‎{{header|Scheme}}: Add implementation)
Line 1,938:
 
}</lang>
 
=={{header|Scheme}}==
{{works with|MIT Scheme}}
{{works with|Guile}}
{{works with|Racket}}
 
The demo code uses <tt>iota</tt> as defined in SRFI-1, so won't work in Schemes lacking that function. Racket will work if you add <tt>(require srfi/1)</tt>.
 
<lang scheme>(define (dec31wd year)
(remainder (apply + (map (lambda (d) (quotient year d)) '(1 4 -100 400))) 7))
 
(define (long? year) (or (= 4 (dec31wd year)) (= 3 (dec31wd (- year 1)))))
 
(display "Long years between 1800 and 2100:") (newline)
(display (filter long? (iota 300 1800)))</lang>
 
{{Out}}
<pre>Long years between 1800 and 2100:
(1801 1807 1812 1818 1824 1829 1835 1840 1846 1852 1857 1863 1868 1874 1880 1885 1891 1896 1903 1908 1914 1920 1925 1931 1936 1942 1948 1953 1959 1964 1970 1976 1981 1987 1992 1998 2004 2009 2015 2020 2026 2032 2037 2043 2048 2054 2060 2065 2071 2076 2082 2088 2093 2099)</pre>
 
 
=={{header|Sidef}}==
1,480

edits