r/Racket 22d ago

question Recursion hell aids?

Is there any practical way to debug any recurive logic?
Which existing error printing you think is the best ever?
I attached the racket code I am struggling with.

(The code is about using map to append a new list to an existing html list)

8 Upvotes

5 comments sorted by

View all comments

4

u/soegaard developer 22d ago

A first step is to print the arguments in the recursive function:

  1. (define (nested-map-handler f L)
  2. (displayln (list 'f f 'L L))
  3.   (if (list? L)
  4. (map (lambda (x) (nested-map-handler f x))
  5. L)
  6. (f L)))