story.scm 939 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/guile -s
  2. !#
  3. (use-modules (ice-9 rdelim))
  4. (define (get-character)
  5. (display "Choose a tall valiant Warrior, a fierce Dragon, or a proud Elf: ")
  6. (read-line))
  7. (define (is-warrior? character)
  8. (eq? character 'warrior))
  9. (define (is-dragon? character)
  10. (eq? character 'dragon))
  11. (define (is-elf? character)
  12. (eq? character 'elf))
  13. (display "This is a mystery novel! Choose your character:\n")
  14. (define character
  15. (let loop
  16. ((string (get-character)))
  17. (cond
  18. ((string-ci=? string "w") 'warrior)
  19. ((string-ci=? string "d") 'dragon)
  20. ((string-ci=? string "e") 'elf)
  21. (else (begin
  22. (loop (get-character)))))))
  23. (cond ((is-dragon? character)
  24. (display "Hello fierce beast! Don't eat me! \n"))
  25. ((is-elf? character)
  26. (display "Hello sir. May I call you Elrond? \n"))
  27. ((is-warrior? character)
  28. (display "Hello. May I call your Wolfgar? \n")))
  29. (display "Your")