Skip to content

Instantly share code, notes, and snippets.

@yamasushi
Created March 18, 2013 03:00
Show Gist options
  • Select an option

  • Save yamasushi/5184710 to your computer and use it in GitHub Desktop.

Select an option

Save yamasushi/5184710 to your computer and use it in GitHub Desktop.
; 生データの列から読んで、アイテム列に変換する手続きを返す。
; アイテムを返す。
; [S]->(S->[I])->(I->I)->(I->bool)-> [I]
; (I->I) でアイテムの変換 (省略可、省略時はなにもしない)
; (I->bool)でフィルタする (省略可、省略時はなにもしない)
(define (%seq%-read-and-map$
%seq%-map %seq%-filter %seq%-concatenate x->%seq%
:key
raw->items ; res ---> items 生データからアイテムリストに変換
(item-map #f ) ; 各アイテムを変換
(item-filter #f ) ; 変換後のフィルタ
)
($ (andfn-mapfilter$ %seq%-map %seq%-filter item-map item-filter)
$ (andfn$ %seq%-concatenate)
$ (andfn-fn$ %seq%-map ($ x->%seq% $ raw->items $) ) $) )
;ジェネレータ版
(define (gread-and-map$ . arg )
(apply %seq%-read-and-map$
(with-module %seq%generator %seq%map)
(with-module %seq%generator %seq%filter)
(with-module %seq%generator %seq%concatenate)
(with-module %seq%generator x->%seq%) arg) )
;遅延シーケンス版
(define (lread-and-map$ . arg )
(apply %seq%-read-and-map$
(with-module %seq%lseq %seq%map)
(with-module %seq%lseq %seq%filter)
(with-module %seq%lseq %seq%concatenate)
(with-module %seq%lseq x->%seq%) arg) )
;ストリーム版
(define (stream-read-and-map$ . arg )
(apply %seq%-read-and-map$
(with-module %seq%stream %seq%map)
(with-module %seq%stream %seq%filter)
(with-module %seq%stream %seq%concatenate)
(with-module %seq%stream x->%seq%) arg) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment