0

I test the following procedure from org-mode

#+name: case-2.1.1-factorial.el
#+BEGIN_SRC elisp
(defun factorial(n)
  (if (= n 1)
      1
      (* n (factorial (- n 1)))))
(trace-function #'factorial)
(factorial 4)
#+END_SRC

#+RESULTS: case-2.1.1-factorial.el
: 24

trace-function does not work as expected as from shell

1 -> (factorial 4)
| 2 -> (factorial 3)
| | 3 -> (factorial 2)
| | | 4 -> (factorial 1)
| | | 4 <- factorial: 1
| | 3 <- factorial: 2
| 2 <- factorial: 6
1 <- factorial: 24

How could make 'trace-function' print the above tracing from org-mode.

  • 1
    trace-function produces its output in a different buffer (*trace-output* by default). You can try (trace-function #'factorial (current-buffer)) but in my experiments that triggered an error in org-babel-insert-result. That's probably a bug, which you might want to report to the Org mode mailing list. – NickD Mar 27 at 14:49
  • ty, I reported it to mailiing-list @NickD – Calculus Mar 28 at 0:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.