X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Futils.lisp;h=6ab351d1f21fc9a780a442638e685eb9ee727011;hb=259f6aaee78865c11889b9b83f3306192fee6bd9;hp=76b396d567355e9527220c8885ae4f5225a0c38c;hpb=07da35c5e99ed9604540d76455330c1e8734b411;p=jscl.git diff --git a/src/utils.lisp b/src/utils.lisp index 76b396d..6ab351d 100644 --- a/src/utils.lisp +++ b/src/utils.lisp @@ -16,14 +16,13 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . -(defvar *newline* " -") +(/debug "loading utils.lisp!") (defmacro concatf (variable &body form) `(setq ,variable (concat ,variable (progn ,@form)))) ;;; This couple of helper functions will be defined in both Common -;;; Lisp and in Ecmalisp. +;;; Lisp and in JSCL (defun ensure-list (x) (if (listp x) x @@ -91,3 +90,14 @@ (let ((key-val (if key (funcall key y) y)) (fn (if test-not-p (complement test-not) test))) (funcall fn x key-val))) + + +(defun interleave (list element &optional after-last-p) + (unless (null list) + (with-collect + (collect (car list)) + (dolist (x (cdr list)) + (collect element) + (collect x)) + (when after-last-p + (collect element)))))