KitKot: Add racket and R7RS

This commit is contained in:
Nikolay Puzanov
2014-11-06 11:22:57 +03:00
parent 69bf5eb4f8
commit 7fdfb8e255
4 changed files with 98 additions and 11 deletions

View File

@@ -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) "? ")))