Question: SBCL: NEED HELP FIXING ERRORS! in clean: FAIL: Nested list remove all elements ACTUAL: NIL EXPECTED: ( NIL NIL ( Cdefun clean ( afunc alist

SBCL: NEED HELP FIXING ERRORS! in clean: FAIL: Nested list remove all elements ACTUAL: NIL EXPECTED: (NIL NIL(Cdefun clean (afunc alist) ; safunc filters a list based on predicate function ispilter alist by applying afunc to its elements, preserving sublist structure
(remove nil ;jensures sublists are filtered out
(mapcar (lambda (elem)
(if (listp elem)
(let ((cleaned (clean afunc elem)))
(if (null cleaned) nil cleaned))
(if (funcall afunc elem)
elem
nill)!
aList))
[defmacro threewayBranch (conditions true-branch false-branch)
isevaluates conditions and executes the corresponding branch
' let I result
(catch 'branch-result
(dolist (clause, conditions)
(when (eval (car clause)) ; evaluated as condition
(throw 'branch-result (progn ,@(car clause))II)1)) ;;cdr clause represents cod
(if result
result
(progn ,@false-branch))I)FAIL: Nested list remove all elements of sublist ACTUAL: (Hello World) EXPECTED: (Hello NIL World)in threewayBranch:; The variable TRUE-BRANCH is defined but never used.; The variable CLAUSE is unbound.FAIL: Got an exception: Execution of a form compiled with errors.Form: (THREEWAYBRANCH ((26)(STRING "x branch body executed"))(NIL (STRING "y branch body executed"))(NIL (STRING "z branch body executed")))Compile-time error: during macroexpansion of (THREEWAYBRANCH (# #)(NIL #)...). Use*BREAK-ON-SIGNALS* to intercept. The variable CLAUSE is unbound.FAIL: Got an exception: Execution of a form compiled with errors.Form: (THREEWAYBRANCH (NIL (STRING "x branch body executed"))((26)(STRING "y branch body executed"))(NIL (STRING "z branch body executed")))Compile-time error: during macroexpansion of (THREEWAYBRANCH (NIL #)(# #)...). Use*BREAK-ON-SIGNALS* to intercept. The variable CLAUSE is unbound.FAIL: Got an exception: Execution of a form compiled with errors.Form: (THREEWAYBRANCH (NIL (STRING "x branch body executed"))(NIL (STRING "y branch body executed"))((26)(STRING "z branch body executed")))Compile-time error: during macroexpansion of (THREEWAYBRANCH (NIL #)(NIL #)...). Use*BREAK-ON-SIGNALS* to intercept. The variable CLAUSE is unbound.FAIL: Got an exception: Execution of a form compiled with errors.Form: (THREEWAYBRANCH ((26)(+20056)(STRING "x branch body executed"))(NIL (STRING "y branch body executed"))(NIL (STRING "z branch body executed")))Compile-time error: during macroexpansion of (THREEWAYBRANCH (# # #)(NIL #)...). Use*BREAK-ON-SIGNALS* to intercept. The variable CLAUSE is unbound.FAIL: Got an exception: Execution of a form compiled with errors.Form: (THREEWAYBRANCH (NIL (STRING "x branch body executed"))((26)(+20056)(STRING "y branch body executed"))(NIL (STRING "z branch body executed")))Compile-time error: during macroexpansion of (THREEWAYBRANCH (NIL #)(# # #)...). Use*BREAK-ON-SIGNALS* to intercept. The variable CLAUSE is unbound.FAIL: Got an exception: Execution of a form compiled with errors.Form: (THREEWAYBRANCH (NIL (STRING "x branch body executed"))(NIL (STRING "y branch body executed"))((26)(+20056)(STRING "z branch body executed")))Compile-time error: during macroexpansion of (THREEWAYBRANCH (NIL #)(NIL #)...). Use*BREAK-ON-SIGNALS* to intercept. The variable CLAUSE is unbound.(defun clean (aFunc aList) ;;aFunc filters a list based on predicate function;;Filter aList by applying aFunc to its elements, preserving sublist structure(remove nil ;;ensures sublists are filtered out(mapcar (lambda (elem)(if (listp elem)(let ((cleaned (clean aFunc elem)))(if (null cleaned) nil cleaned))(if (funcall aFunc elem)elemnil)))aList)))(defmacro threewayBranch (conditions true-branch false-branch);;evaluates conditions and executes the corresponding branch`(let ((result(catch 'branch-result(dolist (clause ,conditions)(when (eval (car clause)) ;; evaluated as condition(throw 'branch-result (progn ,@(cdr clause)))))l)) ;;cdr clause represents co(if resultresult(progn ,@false-branch))))
SBCL: NEED HELP FIXING ERRORS! in clean: FAIL:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!