This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env gosh | |
(use gauche.generator) | |
(use gauche.parseopt) | |
(use srfi-27) ; 乱数 | |
(use srfi-1) ; list | |
(define (make-gm-generator a m x0 y0) | |
(define (f x) | |
(let1 xx (* x x) | |
(+ (* m x) (/ (* 2 (- 1 m) xx) (+ 1 xx) ) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; graph | |
; 「人工知能システムの構成」をogura | |
; 「人工知能の基礎知識」をtahara | |
;グラフのコストを入力するための手続き | |
; 単方向のコスト | |
(define (gcost from to cost) | |
(list (cons (cons from to) cost) ) ) | |
; 双方向のコスト |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use srfi-1) | |
(use srfi-13) | |
(load "graph") | |
(define param-ogura35a `(,ogura-graph35a ,ogura-cost35a ,ogura-h35a )) | |
(define param-ogura35b `(,ogura-graph35b ,ogura-cost35b ,ogura-h35b )) | |
(define param-ogura36 `(,ogura-graph36 ,ogura-cost36 ,ogura-h36 )) | |
(define param-tahara319 `(,tahara-graph35 ,tahara-cost311 ,tahara-h319)) | |
(define param-tahara327 `(,tahara-graph35 ,tahara-cost311 ,tahara-h327)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env gosh | |
(use util.match) | |
; マニュアルからコピー | |
(define (usage) | |
(format (current-error-port) | |
"Usage: ~a regexp file ...\n" *program-name*) | |
(exit 2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env gosh | |
(define (open-with-input-files files proc) | |
(if (null? files) | |
(proc (current-input-port) ) | |
(for-each | |
(lambda (f) | |
(call-with-input-file f proc)) | |
files))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; イテレータ反転 | |
(define-module inverter | |
(use gauche.generator) | |
(use util.stream) | |
; | |
(use util.queue) | |
(use gauche.threads) | |
; | |
(export | |
generator-inverter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ポートの反転 | |
(define-module port-inverter | |
(use gauche.vport) | |
(use gauche.generator) | |
(use gauche.uvector) | |
; | |
(use inverter) | |
(export | |
mtport-inverter | |
)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; http-getのパラメタ指定してhttp-get、procに仮想ポートを渡す。 | |
(define (call-with-input-http http-param proc :key (queue-size 100) (buffer-size 8000) ) | |
(let1 inverter (mtport-inverter :queue-size queue-size :buffer-size buffer-size) | |
(inverter | |
(^[outp] (apply http-get (append http-param `(:sink ,outp :flusher ,(^ _ (flush outp) #t) )))) | |
(^[inp] (proc inp) ) ) ) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use gauche.uvector) | |
(define (uvector-slices u k) | |
(let [(uvclass (class-of u)) | |
(l (uvector-length u))] | |
(receive (n r) (quotient&remainder l k) | |
(let1 s (* n k) | |
(let loop [(i s) | |
(d (if (= r 0) | |
'() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use gauche.generator) | |
(use gauche.uvector) | |
(define (call-with-port-chunk port chunk-size size proc) | |
(let1 chunk (make-u8vector chunk-size) | |
(cond | |
[ (eqv? size 0) #t ] | |
[ (not size) | |
(until (read-block! chunk port 0 chunk-size) eof-object? => len |
OlderNewer