javascriptのif else文ファイル書き込みのcommon lispプログラム
(書きかけ...)
gist
https://gist.github.com/taroyanaka/98d93dc2f455133d1dd02aca899e5e4c#file-js-generate-lisp
環境
mac OS 10.12.6
SBCL 1.4.1
js-generate.lisp
(setq lst (list "if(){}"))
(setq lst (list "if(){}" "else{}"))
(setq lst (list "if(){}" "else if(){}" "else{}"))
(setq lst (list "if(){}" "else if(){}" "else if(){}" "else{}"))
(defun add-to-tail (l x) (reverse (cons x (reverse l))) )
(defun list-insert-at (lst index new-value)
(let ((retval nil))
(loop for i from 0 to (- (length lst) 1) do
(when (= i index)
(push new-value retval))
(push (nth i lst) retval))
(when (>= index (length lst))
(push new-value retval))
(nreverse retval)))
(list-insert-at lst 1 "else if(){}")
(defun cat (lst)
(with-output-to-string (stream) (dolist (char lst) (princ char stream)))
)
(cat lst)
参考
https://ja.wikibooks.org/wiki/Lisp/%E5%9F%BA%E6%9C%AC%E3%81%8B%E3%82%89%E3%81%95%E3%82%89%E3%81%AB%E4%B8%80%E6%AD%A9%E9%80%B2%E3%82%93%E3%81%A7/%E6%96%87%E5%AD%97%E5%88%97
https://stackoverflow.com/questions/4387570/in-common-lisp-how-can-i-insert-an-element-into-a-list-in-place
https://stackoverflow.com/questions/13359025/adding-to-the-end-of-list-in-lisp