Clean source
This commit is contained in:
parent
b5abcafaf8
commit
888f8aef0f
30
kot-kit.scm
30
kot-kit.scm
@ -1,31 +1,25 @@
|
|||||||
(import (rnrs io ports (6))) ;; Guile
|
(import (rnrs io ports (6))) ;; Guile
|
||||||
;(require rnrs/io/ports-6) ;; Racket
|
;(require rnrs/io/ports-6) ;; Racket
|
||||||
|
|
||||||
(setlocale LC_ALL "")
|
(setlocale LC_ALL "") ;; Guile
|
||||||
|
|
||||||
(define out-port (current-output-port))
|
|
||||||
(define in-port (current-input-port))
|
|
||||||
|
|
||||||
(define (println . params)
|
(define (println . params)
|
||||||
(for-each (lambda (x) (display x out-port)) params)
|
(for-each (lambda (x) (display x)) params)
|
||||||
(newline out-port) #f)
|
(newline))
|
||||||
|
|
||||||
;; Helper functions
|
;; Helper functions
|
||||||
|
(define (answer . params)
|
||||||
|
(for-each (lambda (x) (display x)) params)
|
||||||
|
(flush-output-port (current-output-port))
|
||||||
|
(get-line (current-input-port)))
|
||||||
|
|
||||||
(define (yes? . params)
|
(define (yes? . params)
|
||||||
(for-each (lambda (x) (display x out-port)) params)
|
(let ((ans (apply answer (append params '("? ")))))
|
||||||
(display "? " out-port)
|
|
||||||
(flush-output-port out-port)
|
|
||||||
(let ((ans (get-line in-port)))
|
|
||||||
(if (= (string-length ans) 0)
|
(if (= (string-length ans) 0)
|
||||||
#f
|
#f
|
||||||
(or
|
(or
|
||||||
(equal? (string-ref ans 0) #\y)
|
(char-ci=? (string-ref ans 0) #\y)
|
||||||
(equal? (string-ref ans 0) #\д)))))
|
(char-ci=? (string-ref ans 0) #\д)))))
|
||||||
|
|
||||||
(define (answer . params)
|
|
||||||
(for-each (lambda (x) (display x out-port)) params)
|
|
||||||
(flush-output-port out-port)
|
|
||||||
(get-line in-port))
|
|
||||||
|
|
||||||
;; Copy tree
|
;; Copy tree
|
||||||
(define (copy-pet-tree pet-tree)
|
(define (copy-pet-tree pet-tree)
|
||||||
@ -65,7 +59,7 @@
|
|||||||
(call-with-input-file TREE-FILE-NAME read)
|
(call-with-input-file TREE-FILE-NAME read)
|
||||||
'())))
|
'())))
|
||||||
(let ((tree (game-round pet-tree "Кот")))
|
(let ((tree (game-round pet-tree "Кот")))
|
||||||
(newline out-port)
|
(newline)
|
||||||
(if (yes? "Играем еще")
|
(if (yes? "Играем еще")
|
||||||
(loop tree)
|
(loop tree)
|
||||||
(begin
|
(begin
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user