Gauche:Memoize

Gauche:Memoize

yamasushi(2013/04/10 00:21:29 UTC)メモ化のための小物をまとめてみます。
yamasushi(2013/04/13 11:34:10 UTC) Gauche:マニュアルにアクセスで使用しています。
yamasushi(2013/04/16 10:46:28 UTC)Gauche:マニュアルにアクセスで使っていたのですが、instance-poolでやったほうが簡単でした。(→Gauche:infoファイルにアクセス)
yamasushi(2013/05/01 00:52:10 UTC)Gauche:メモ化から移行しました。

; info-file <string> ---> info <info-file>
; infoをたびたび開くのを抑止してメモ化
(define info-node-open-file
  (make-memoized (make-hash-table 'string=?) ($ open-info-file $ find-info-file $) ) )
; info node-name ---> [node info-index] or #f
(define-method %info-node-get-index% ( (info <info-file>) node-name )
  (and-let* [ [_ (string? node-name) ]
              [_ info  ]
              [node (info-get-node info node-name)] ]
    (let1 info-index (make-tree-map string=? string<?)
      (for-each
        (match-lambda
          [ (keyword . nodename)
          
          ....
          
        (info-parse-menu node) )
      (list node info-index)
      ) ) )
; メモ化
(define info-node-get-index
  (make-memoized
    (make-hash-table 'string=?)
    %info-node-get-index%
    (^(info node-name) (string-append (ref info 'path) node-name )) ) )

メモ化についての資料

関連

その他



yamasushi(2013/04/14 08:27:35 UTC) 改良してみました。

使用例



Tags: メモワイズ, メモ化, memoize


Last modified : 2013/05/01 00:58:55 UTC