该trace
函数允许您可视化 LISP REPL 中的函数调用。
示例输出sbcl
* (defun help(a x)
(if (null x) nil
(cons (cons a (car x)) (help a (cdr x)))))
HELP
* (defun partition(x)
(if (null x) '(nil)
(append (help (car x) (partition(cdr x))) (partition(cdr x)))))
PARTITION
* (trace help)
(HELP)
* (trace partition)
(PARTITION)
* (partition '(a b))
0: (PARTITION (A B))
1: (PARTITION (B))
2: (PARTITION NIL)
2: PARTITION returned (NIL)
2: (HELP B (NIL))
3: (HELP B NIL)
3: HELP returned NIL
2: HELP returned ((B))
2: (PARTITION NIL)
2: PARTITION returned (NIL)
1: PARTITION returned ((B) NIL)
1: (HELP A ((B) NIL))
2: (HELP A (NIL))
3: (HELP A NIL)
3: HELP returned NIL
2: HELP returned ((A))
1: HELP returned ((A B) (A))
1: (PARTITION (B))
2: (PARTITION NIL)
2: PARTITION returned (NIL)
2: (HELP B (NIL))
3: (HELP B NIL)
3: HELP returned NIL
2: HELP returned ((B))
2: (PARTITION NIL)
2: PARTITION returned (NIL)
1: PARTITION returned ((B) NIL)
0: PARTITION returned ((A B) (A) (B) NIL)
((A B) (A) (B) NIL)
除此之外,我不完全确定如何提供更多帮助。