代码之家  ›  专栏  ›  技术社区  ›  Fred_2

#符号的LISP含义

  •  2
  • Fred_2  · 技术社区  · 9 年前

    口齿不清 我的代码有一个函数(nfa regex compile),它创建一个 欺骗

    在本例中,我将一个序列作为表达式,但我不理解为什么,如果我给出两个以上的符号,函数会产生 (# #) 而不是继续生成新的状态。

    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) (# #))))
    

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

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

    Automaton for the regular expression abc

    1 回复  |  直到 9 年前
        1
  •  7
  •   Xach    9 年前

    *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)))
    

    这个 真实的 结构从未改变,只有印刷的表现。