Odd word problem: Difference between revisions

Line 50:
return 0;
}</lang>
 
=={{header|Common Lisp}}==
Even words are straightforward. For odd words, the final punctuation is printed by a closure passed back up the caller chain.
<lang lisp>(defun do-even (&aux (c (read-char)))
(if (alpha-char-p (write-char c))
(do-even)
(char/= c #\.)))
 
(defun do-odd (&aux (c (read-char)))
(if (alpha-char-p c)
(prog1
(do-odd)
(write-char c))
(lambda ()
(write-char c)
(char/= #\.))))
 
(defun do-char (is-even)
(if is-even
(do-even)
(funcall (do-odd))))
 
(loop for x = t then (not x)
while (do-char x))</lang>
 
=={{header|Factor}}==
Anonymous user