Last Friday of each month: Difference between revisions

→‎{{header|Elm}}: add Emacs Lisp
(→‎{{header|Elm}}: add Emacs Lisp)
Line 1,362:
December 26, 2003
</pre>
 
=={{header|Emacs Lisp}}==
<lang lisp>(require 'calendar)
 
(defun last-sunday (year)
"Print the last Friday in each month of year"
(mapcar (lambda (month)
(let*
((days (number-sequence 1 (calendar-last-day-of-month month year)))
(mdy (mapcar (lambda (x) (list month x year)) days))
(weekdays (mapcar #'calendar-day-of-week mdy))
(lastfriday (1+ (cl-position 5 weekdays :from-end t)))
)
(insert (format "%02i-%02i-%02i \n" year month lastfriday))
))
(number-sequence 1 12)))
 
(last-sunday 2012)</lang>
{{output}}
<pre>2012-01-27
2012-02-24
2012-03-30
2012-04-27
2012-05-25
2012-06-29
2012-07-27
2012-08-31
2012-09-28
2012-10-26
2012-11-30
2012-12-28 </pre>
 
=={{header|Erlang}}==
Anonymous user