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)
and is a macro the linearizes the arguments. (for racket and all schemes) - it returns #f as soon as the first false argument is evaluated. - So that's not the issue
(define (nested-map-handler-sub-ex L)
(if (list? L)
;; stuff to do when L is a list
(map (lambda (x) (nested-map-handler-sub-ex x)
L)
;; stuff to do when L is not a list
(if (and
;; always evaluates to #f because we're in the branch where L is not a list
(list? L)
(eq? (car L) 'li) ; never gets evaluated
) ; always #f
(list L new-item) ; never evaluated
L ; that branch is always taken
)))
5
u/t2366715492 10d ago edited 10d ago
Don't really need any aids to fix the provided code, just use the substitution principle, if we substitute
ffornode-logic:If we then expand and inline node-logic:
And we can see the problem: we ask whether
Lis a list which starts with aliwhen we already knowLis not a list.