KitKot: Add racket and R7RS
This commit is contained in:
22
kot-kit.scm
22
kot-kit.scm
@@ -17,20 +17,21 @@
|
||||
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
;; THE SOFTWARE.
|
||||
|
||||
(import (rnrs io ports (6))) ;; Guile
|
||||
;;(require rnrs/io/ports-6) ;; Racket
|
||||
|
||||
(setlocale LC_ALL "") ;; Guile
|
||||
|
||||
(define (println . params)
|
||||
(for-each (lambda (x) (display x)) params)
|
||||
(newline))
|
||||
(cond-expand
|
||||
(guile
|
||||
(import (rnrs io ports (6)))
|
||||
(setlocale LC_ALL "")
|
||||
(define read-line get-line))
|
||||
(else ;; R7RS (tested on Chibi and Gauche)
|
||||
(import (scheme base)
|
||||
(scheme file)
|
||||
(scheme r5rs))))
|
||||
|
||||
;; Helper
|
||||
(define (answer . params)
|
||||
(for-each (lambda (x) (display x)) params)
|
||||
(flush-output-port (current-output-port))
|
||||
(get-line (current-input-port)))
|
||||
(read-line (current-input-port)))
|
||||
|
||||
(define (yes? . params)
|
||||
(let ((ans (apply answer (append params '("? ")))))
|
||||
@@ -56,7 +57,8 @@
|
||||
(if (null? pet-tree)
|
||||
(if (yes? "Это " (car y-pet))
|
||||
(begin
|
||||
(println "Ура, я угадал!")
|
||||
(display "Ура, я угадал!")
|
||||
(newline)
|
||||
'())
|
||||
(let* ((name (answer "Сдаюсь! Кто это? "))
|
||||
(feature (answer "Чем " name " отличается от " (car y-pet) "? ")))
|
||||
|
||||
Reference in New Issue
Block a user