fork download
  1. (defun fortunecookie ()
  2. (princ "名前または学籍番号を入力:")
  3. (let* ((id (read-line))
  4. ;; 今日の日付を取得して文字列にする(YYYYMMDD形式)
  5. (date (multiple-value-bind (sec min hour day month year)
  6. (get-decoded-time)
  7. (format nil "~4,'0d~2,'0d~2,'0d" year month day)))
  8. ;; 名前と日付をつなげる
  9. (combined (concatenate 'string id date))
  10. ;; 各文字の文字コードを合計
  11. (seed (reduce #'+ (map 'list #'char-code combined)))
  12. ;; seedを5で割った余りでおみくじを選ぶ
  13. (index (mod seed 5))
  14. (result (nth index
  15. '("大吉! 挑戦を続けよう"
  16. "中吉! 今日は集中の日"
  17. "小吉! まずは一歩"
  18. "吉! 粘り勝ちを目指そう"
  19. "凶...でも明日がある!"))))
  20. (format t "結果:~A~%" result)))
  21.  
  22. (fortunecookie)
Success #stdin #stdout 0.01s 29264KB
stdin
彰吾
stdout
名前または学籍番号を入力:結果:大吉! 挑戦を続けよう