author | Alan Dipert
<alan@dipert.org> 2021-07-26 02:13:56 UTC |
committer | Alan Dipert
<alan@dipert.org> 2021-07-26 02:13:56 UTC |
parent | d1f691575dd4858bb59afa6a8b79b4dc33f97192 |
boot.lisp | +6 | -10 |
diff --git a/boot.lisp b/boot.lisp index b04c674..ec63e9e 100644 --- a/boot.lisp +++ b/boot.lisp @@ -485,12 +485,9 @@ list function))) -(defun %remove (x list) - (%js "Cons.fromArray(~{})" - (%js "List.toArray(~{}).filter(x => ~{}(x, ~{}) === null)" - list - #'eq - x))) +(defun %mapcan (function list) + (%js "[...~{}].reduce((x, y) => Cons.append(x, y))" + (%mapcar function list))) (%export 'do*) (defmacro do* (step-forms &rest more) @@ -502,10 +499,9 @@ (bindings (%mapcar (lambda (step-form) (list (car step-form) (cadr step-form))) step-forms)) - (assignments (%remove nil - (%mapcar (lambda (step-form) + (assignments `(setq ,@(%mapcan (lambda (step-form) (when (caddr step-form) - `(setq ,(car step-form) ,(caddr step-form)))) + (list (car step-form) (caddr step-form)))) step-forms)))) `(block nil (let* ,bindings @@ -513,7 +509,7 @@ ,begin# (if ,end-test-form (return (progn ,@result-forms))) - ,@assignments + ,assignments ,@body (go ,begin#))))))