Vim ScriptはあったのにEmacs Lispがないなんて...
ということで書きました。
zundoko.el
(setq z "ズン")
(setq d "ドコ")
(setq k "キ・ヨ・シ!\n")
(setq ans (list z z z z d))
(defun get_zundoko ()
(if (eq 1 (random 2)) z d))
(defun get_zundoko_seq (c n)
(if c (reverse (cons n (reverse c))) (list n)))
(defun truncate_zundoko_seq (s)
(reverse (butlast (reverse s) (- (length s) 5))))
(defun next_zundoko_seq (c n)
(truncate_zundoko_seq (get_zundoko_seq c n)))
(defun do_zundoko(&optional c)
(let (n)
(if (equal c ans)
(princ k)
((lambda ()
(setq n (get_zundoko))
(princ n)
(do_zundoko (next_zundoko_seq c n)))))))
(do_zundoko)
実行結果
$ emacs --script zundoko.el
ズンドコドコズンズンドコドコズンドコドコズンズンズンズンドコキ・ヨ・シ!
$ emacs --version
GNU Emacs 24.5.1
Copyright (C) 2015 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.