From d10b24c2c848fe561904c30376d0ecc6e76685d4 Mon Sep 17 00:00:00 2001 From: paku Date: Mon, 27 May 2024 19:11:27 +0900 Subject: [PATCH] Improve find-builtin-symbols --- src/hsx.lisp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/hsx.lisp b/src/hsx.lisp index 2d1e951..ce66283 100644 --- a/src/hsx.lisp +++ b/src/hsx.lisp @@ -45,15 +45,13 @@ (error "The body of the hsx macro must be a single form.")) (find-builtin-symbols (car form))) -(defun find-builtin-symbols (tree) - (if tree - (cons (let ((first-node (first tree))) - (if (listp first-node) - (find-builtin-symbols first-node) - (or (find-symbol (string first-node) :hsx/builtin) - first-node))) - (mapcar (lambda (node) - (if (listp node) - (find-builtin-symbols node) - node)) - (rest tree))))) +(defun find-builtin-symbols (node) + (if (atom node) + (or (find-symbol (string node) :hsx/builtin) + node) + (cons (find-builtin-symbols (car node)) + (mapcar (lambda (n) + (if (listp n) + (find-builtin-symbols n) + n)) + (cdr node)))))