我刚开始使用LISP,来自C的背景.到目前为止它很有趣,虽然有一个令人难以置信的学习曲线(我也是一个emacs新手).
无论如何,我对以下代码有一个愚蠢的问题来解析来自c源的include语句 - 如果有人可以对此发表评论并建议解决方案,那将会有很大帮助.
(defun include-start ( line ) (search "#include " line)) (defun get-include( line ) (let ((s (include-start line))) (if (not (eq NIL s)) (subseq line s (length line))))) (get-include "#include")
我希望最后一行能够返回
""
但实际结果是
"#include"
有什么想法吗?
(defun include-start (line) "returns the string position after the '#include ' directive or nil if none" (let ((search-string "#include ")) (when (search search-string line) (length search-string)))) (defun get-include (line) (let ((s (include-start line))) (when s (subseq line s))))