Question: NEED HELP: SBCL common lisp. I ' m getting the error that the clause in threewayBranch is unbound. also, the clean function is failing some

NEED HELP: SBCL common lisp.
I'm getting the error that the clause in threewayBranch is unbound.
also, the clean function is failing some tests.
ex: FAIL: Multiple nested lists remove some things ACTUAL: (NIL (c (b a (NIL x NIL) NIL) y) NIL (NIL z NIL)) EXPECTED: ((c (b a (x)) y)(z)).
example of error message in threewayBranch macro: 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.
please help me figure out how to fix these issues! ```
(defun clean (aFunc aList) ;;aFunc filters a list based on predicate function
;;Filter aList by applying aFunc to its elements, preserving sublist structure."
(mapcar (lambda (elem)
(if (listp elem)
(clean aFunc elem) ;;recursively clean sublists
(if (funcall aFunc elem)
elem
nil)))
aList))
(defmacro threewayBranch (conditions true-branch false-branch) ;;true-branch- the actions to execute
;;simplified macro that evaluates conditions and executes the corresponding branch
`(let ((result (catch 'branch-result ;;catch for control flow
(dolist (clause ,conditions)
(when (eval (car clause))
(throw 'branch-result (progn ,@(cdr clause))))))))
(if result
result
(progn ,@false-branch)))) ;;allows multiple expressions to be evaluated in sequence
```
NEED HELP: SBCL common lisp. I ' m getting the

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!