mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 21:59:17 +02:00
They can be close()d explicitly with close-file-descriptor, and will close() on gc, but only explicitly closing the last port on them will close the fileno. Notably needed for network sockets where we open separate input and output ports on the same socket.
28 lines
834 B
Scheme
28 lines
834 B
Scheme
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
; File: tak.sch
|
|
; Description: TAK benchmark from the Gabriel tests
|
|
; Author: Richard Gabriel
|
|
; Created: 12-Apr-85
|
|
; Modified: 12-Apr-85 09:58:18 (Bob Shaw)
|
|
; 22-Jul-87 (Will Clinger)
|
|
; Language: Scheme
|
|
; Status: Public Domain
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;; TAK -- A vanilla version of the TAKeuchi function
|
|
|
|
(define (tak x y z)
|
|
(if (not (< y x))
|
|
z
|
|
(tak (tak (- x 1) y z)
|
|
(tak (- y 1) z x)
|
|
(tak (- z 1) x y))))
|
|
|
|
;;; call: (tak 18 12 6)
|
|
|
|
(let ((input (with-input-from-file "input.txt" read)))
|
|
(time
|
|
(let loop ((n 500) (v 0))
|
|
(if (zero? n)
|
|
v
|
|
(loop (- n 1) (tak 18 12 (if input 6 0)))))))
|