目前我正在研究一种跨会话使用哈希表的 elisp 主要模式。所以每次初始化主模式时,表都会加载到内存中。在会话期间和结束时,它们被写入文件。我当前的实现以下列方式写入数据:
(with-temp-buffer
(prin1 hash-table (current-buffer))
(write-file ("path/to/file.el"))))
Run Code Online (Sandbox Code Playgroud)
在会话开始时加载数据是通过读取完成的,是这样的:
(setq name-of-table (car
(read-from-string
(with-temp-buffer
(insert-file-contents path-of-file)
(buffer-substring-no-properties
(point-min)
(point-max))))))))
Run Code Online (Sandbox Code Playgroud)
它有效,但我觉得这不是最漂亮的方法。我的目标是:我希望这个主要模式变成一个漂亮的干净包,将它自己的数据存储在存储包的其他数据的文件夹中。
我必须迭代一个矢量,而矢量又将地图作为其项目.我需要比较下一张地图,有时我需要查看我们之前看过的地图.所以有必要展望未来/看后面的功能.我当前的方法是有效的,但我想这是丑陋的,单一的Clojure,我认为必须有更好的(更规范的)方法来实现这一点.
(let [result (apply str (map (fn [{position-before :position compound-before :compund } ; previous term (unfortunately we need to compare all three)
{:keys [word position line tag stem compound grammarpos] :or {grammarpos "0" stem "" } } ; this maps to the current word
{position-ahead :position compound-ahead :compound line-ahead :line}] ; this is for lookahead
(do some stuff)) ;; now we have position, which is our current position, position-before and position-after to compare with each other
;; this is how …Run Code Online (Sandbox Code Playgroud)