Skip to content

Instantly share code, notes, and snippets.

@yamasushi
yamasushi / gm.scm
Created July 16, 2012 05:27
Gumowski-mira写像の点列生成(gnuplotで描画する)
#!/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) ) )
@yamasushi
yamasushi / t.scm
Created July 20, 2012 22:22
http-getから入力ポートをつくりだすための試験場
(use rfc.http)
(use gauche.generator)
(use util.stream)
(define (http-hook-receiver proc)
(lambda (code hdrs total retr)
(let loop [ ]
(receive (port size) (retr)
(cond
[ (eqv? size 0) #t]
@yamasushi
yamasushi / graph.scm
Created July 22, 2012 06:37
探索アルゴリズムの実装(グラフ定義)
; graph
; 「人工知能システムの構成」をogura
; 「人工知能の基礎知識」をtahara
;グラフのコストを入力するための手続き
; 単方向のコスト
(define (gcost from to cost)
(list (cons (cons from to) cost) ) )
; 双方向のコスト
@yamasushi
yamasushi / tansaku-0.scm
Created July 22, 2012 06:38
探索アルゴリズムの実装(アルゴリズム)
(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))
@yamasushi
yamasushi / grep.scm
Created July 22, 2012 06:41
Gaucheマニュアルのgrepサンプルを改造してみる。
#!/usr/bin/env gosh
(use util.match)
; マニュアルからコピー
(define (usage)
(format (current-error-port)
"Usage: ~a regexp file ...\n" *program-name*)
(exit 2))
@yamasushi
yamasushi / cat.scm
Created July 22, 2012 06:42
Gaucheマニュアルのcatサンプルを改造してみる。
#!/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)))
@yamasushi
yamasushi / gist:3162414
Created July 23, 2012 07:25 — forked from psihy/gist:2206070
いかにしておっぱい画像をダウンロードするか~2012 Scheme(Gauche)編
; Gauche 0.9.2
(use srfi-43)
(use rfc.http)
(use rfc.json)
(use rfc.uri)
(use util.list)
(use util.match)
(use file.util)
(use gauche.threads)
@yamasushi
yamasushi / web-helper.scm
Created July 24, 2012 10:47
webアクセスに使う小物群。
(define-module web-helper
(use rfc.http)
(use rfc.uri)
(use sxml.ssax)
(use komono)
(use gauche.threads)
(use gauche.generator)
(use util.queue)
(use gauche.vport)
@yamasushi
yamasushi / mt.scm
Created July 25, 2012 06:48
スレッドを使ってhttp-getからキャラクタジェネレータを作る。そして仮想ポートをつくる。
; スレッドを使ってhttp-getからキャラクタジェネレータを作る。
; そして仮想ポートをつくる。
; https://gist.github.com/3174805
(use rfc.http)
(use gauche.threads)
(use gauche.generator)
(use util.queue)
(use gauche.vport)
(use gauche.uvector)
(use sxml.ssax)
@yamasushi
yamasushi / producer-consumer.scm
Created July 25, 2012 23:19
イテレータの反転をスレッドで実装すると、プロデューサ・コンシューマパターンになる。
; イテレータの反転をスレッドで実装すると、プロデューサ・コンシューマパターンになる。
(use rfc.http)
(use gauche.threads)
(use gauche.generator)
(use util.queue)
(use gauche.vport)
(use gauche.uvector)
(use sxml.ssax)