debugging - Lisp unroll/partial eval function -


is there way show evaluation steps in common lisp follows:

> (defun fac (n) (if (= n 0) 0 (if (= n 1) 1 (* n (fac (- n 1)))))) fac > (step-by-step (fac 3)) 0: (fac 3) 1: (* 3 (fac 2)) 3: (* 3 (* 2 (fac 1))) 4: (* 3 (* 2 (1))) 5: (* 3 2) 6: 6 result: 6 

looking way visualize recursion , return values in general small course. know of (step fn) , (optimize (debug 3))) unfortunately not produce desired output, or don't know how tell to.

note: non-emacs/slime solution preferred

it's not asked for, , specific output implementation dependent, may milage out of standard trace. won't show expansion showed, it's way meet some of requirements

[to] visualize recursion , return values in general … see whole expression on each step. having debug print of each function call.

many implementations include additional arguments can customize how things traced, gets printed, etc. here's example of default behavior sbcl:

cl-user> (defun fac (n) (if (= n 0) 0 (if (= n 1) 1 (* n (fac (- n 1)))))) fac cl-user> (trace fac) (fac) cl-user> (fac 3)   0: (fac 3)     1: (fac 2)       2: (fac 1)       2: fac returned 1     1: fac returned 2   0: fac returned 6 ;=> 6 

in clisp:

cl-user> (fac 3) 1. trace: (fac '3) 2. trace: (fac '2) 3. trace: (fac '1) 3. trace: fac ==> 1 2. trace: fac ==> 2 1. trace: fac ==> 6 ;=> 6 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -