Add tags

Add tags to the following comment
設定ファイルのフォーマットは S式の連想リストです。
ファイルの内容を一時バッファに格納し、そのバッファを
read で読み込んでいます。

ファイル:ShowPrice.ini
((item-name . りんご)
 (item-cost . 200))

> (show-price)
=> "「りんご」は210円(税込み)"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
(defun show-price ()
  (let ((call-with-input-file #'(lambda (filename proc)
                                  (with-temp-buffer
                                    (progn (insert-file-contents filename)
                                           (funcall proc (current-buffer))))))
        (call-with-name&cost #'(lambda (alist proc)
                                 (funcall proc
                                          (cdr (assq 'item-name alist))
                                          (cdr (assq 'item-cost alist)))))
        (call-with-add-tax #'(lambda (rate base proc)
                               (funcall proc (/ (* base (+ rate 100)) 100)))))
    (funcall call-with-input-file (expand-file-name "ShowPrice.ini")
             #'(lambda (in)
                 (funcall call-with-name&cost (read in)
                          #'(lambda (name cost)
                              (funcall call-with-add-tax 5 cost
                                       #'(lambda (cost)
                                           (format "「%s」は%d円(税込み)" name cost)))))))))

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...