Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl
# https://gist.github.com/yamasushi/311c5c424356abf645a2
use strict;
use warnings;
use utf8;
binmode STDIN,":utf8";
binmode STDOUT,":utf8";
while(<>){
chomp;
gosh> (load "./twitterland-examples")
(-< yamasushi <@yamasushi : "まじです"> [@yamasushi : <@yamasushi : "つぶやき,はじめます">])
(-< null <@shuji : "まじで?"> [@null : <@yamasushi : "つぶやき,はじめます">])
(-< null <@yamasushi : "つぶやき,はじめます"> [@null : #f])
(-< shuji <@shuji : "まじで?"> [@shuji : #f])
(-< yamasushi <@yamasushi : "つぶやき,はじめます"> [@yamasushi : #f])
(-< null <@yamasushi : "まじです"> [@null : <@shuji : "まじで?">])
(-> shuji <@yamasushi : "まじです"> [@shuji : <@shuji : "まじで?">])
(-> yamasushi <@shuji : "まじで?"> [@yamasushi : <@yamasushi : "つぶやき,はじめます">])
!! Index - モジュール索引 : compat.norational --> compat.norational - 有理数のない算術演算 --> X
!! Index - モジュール索引 : dbi --> dbi - データベース非依存アクセス層 --> X
!! Index - モジュール索引 : gauche.dictionary --> gauche.dictionary - ディクショナリフレームワーク --> X
!! Index - モジュール索引 : text.progress --> text.progress - テキスト端末上でプログレスを表示する --> X
!! Index - モジュール索引 : text.sql --> text.sql - SQLのパーズと構築 --> X
!! Index - モジュール索引 : util.relation --> util.relation - リレーションフレームワーク --> X
!! Index - モジュール索引 : util.sparse --> util.sparse - 疎なデータコンテナ --> X
!! Index - モジュール索引 : util.trie --> util.trie - Trie --> X
!! Index - 手続きと構文索引 : <sql-parse-error> --> text.sql - SQLのパーズと構築 --> X
!! Index - 手続きと構文索引 : make-text-progress-bar --> text.progress - テキスト端末上でプログレスを表示する --> X
@yamasushi
yamasushi / t.scm
Created August 3, 2012 03:50
イテレータの反転をつかったパイプライン。
(use gauche.generator)
(use text.tr)
(define (generator-inverter)
(^[produce consume] (consume (generate produce) ) ) )
(define (pipeline inverter cmd-in cmd-out)
(^[ g yield]
(inverter
(^[yield]
@yamasushi
yamasushi / port-dump.scm
Created July 28, 2012 08:13
ポートのダンプをするジェネレータ。
(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
@yamasushi
yamasushi / uvslices.scm
Created July 28, 2012 06:10
Slices of unifom vector(ユニフォームベクタのスライス)
(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)
'()
@yamasushi
yamasushi / call-with-input-http.scm
Created July 27, 2012 06:31
call-with-input-httpを「ポートの反転」で書く。
; 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) ) ) ) )
@yamasushi
yamasushi / port-inverter.scm
Created July 27, 2012 06:28
ポートの反転
; ポートの反転
(define-module port-inverter
(use gauche.vport)
(use gauche.generator)
(use gauche.uvector)
;
(use inverter)
(export
mtport-inverter
))
@yamasushi
yamasushi / inverter.scm
Created July 27, 2012 04:14
イテレータ反転
; イテレータ反転
(define-module inverter
(use gauche.generator)
(use util.stream)
;
(use util.queue)
(use gauche.threads)
;
(export
generator-inverter
@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)))