LISP意思是#符号

Fre*_*d_2 2 lisp common-lisp

在我的Lisp代码中,我有函数(nfa-regex-compile),它创建了一个cons的列表,包含初始状态,转换和最终状态(表示自动机的节点),从作为参数给出的正则表达式开始.

在这种情况下,我把一个序列作为表达式,但我不明白为什么,如果我给出两个以上的符号,函数产生(##)而不是继续生成新的状态.

CL-USER 39 : 3 > (nfa-regex-compile '(seq a))

((INITIAL 0) ((DELTA 0 A 1) (FINAL 1)))


CL-USER 40 : 3 > (nfa-regex-compile '(seq a b))

((INITIAL 0) ((DELTA 0 A 1) ((DELTA 1 B 2) (FINAL 2))))


CL-USER 41 : 3 > (nfa-regex-compile '(seq a b c)) 

((INITIAL 0) ((DELTA 0 A 1) ((DELTA 1 B 2) (# #))))


CL-USER 42 : 3 > (nfa-regex-compile '(seq a b c d e f))

((INITIAL 0) ((DELTA 0 A 1) ((DELTA 1 B 2) (# #))))
Run Code Online (Sandbox Code Playgroud)

例如,如果我有序列abc,自动机应该是:

(INITIAL 0) (DELTA 0 A 1) (DELTA 1 B 2) (DELTA 2 C 3) (FINAL C)
Run Code Online (Sandbox Code Playgroud)

自动机为正则表达式abc

Xac*_*ach 6

打印时,标准变量*print-level*控制打印机下降到嵌套结构的深度.如果结构深度超过该级别,则打印机停止并打印裸露#而不是更多结构.

例如:

* (defvar *structure*
    '(:level-1 :level-1
      (:level-2 :level-2 :level-2)
      (:level-2 :level-2 (:level-3 :level-3
                          (:level-4) :level-3))))

* (dotimes (i 5)
    (let ((*print-level* i))
      (print *structure*)))

# 
(:LEVEL-1 :LEVEL-1 # #) 
(:LEVEL-1 :LEVEL-1 (:LEVEL-2 :LEVEL-2 :LEVEL-2) (:LEVEL-2 :LEVEL-2 #)) 
(:LEVEL-1 :LEVEL-1 (:LEVEL-2 :LEVEL-2 :LEVEL-2)
 (:LEVEL-2 :LEVEL-2 (:LEVEL-3 :LEVEL-3 # :LEVEL-3))) 
(:LEVEL-1 :LEVEL-1 (:LEVEL-2 :LEVEL-2 :LEVEL-2)
 (:LEVEL-2 :LEVEL-2 (:LEVEL-3 :LEVEL-3 (:LEVEL-4) :LEVEL-3)))
Run Code Online (Sandbox Code Playgroud)

实际结构不会改变,仅其打印表示.

此变量有时会在调试器中反弹,以避免打印严重嵌套的结构.有关详细信息,请参阅实施文档.