匿名 #6643(2008/07/02 16:59 GMT) [ Emacs Lisp ] Rating0/0=0.00
設定ファイルのフォーマットは 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)))))))))
Rating0/0=0.00-0+
[ reply ]
匿名
#6643()
[
Emacs Lisp
]
Rating0/0=0.00
(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)))))))))Rating0/0=0.00-0+
[ reply ]