diff --git a/kutils.lisp b/kutils.lisp index 41a777f..99d946b 100644 --- a/kutils.lisp +++ b/kutils.lisp @@ -101,12 +101,17 @@ string, it will be used as the class's docstring." :accessor (mksymb name #\- slot))) ,docstring ,@body)) - (defun ,ctor (&key ,@(append (inherited-slots supers) - slots)) - (make-instance (find-class ,name t nil) - ,@(flatten (build-arg-list all-slots)))) t))) +(defun zip (&rest lsts) + "Zip together elements from each list: (zip '(a b c) '(1 2 3)) +produces '((a 1) (b 2) (c 3))." + (labels ((zip-acc (lsts) + (unless (some #'null lsts) + (cons (mapcar #'car lsts) (zip-acc (mapcar #'cdr lsts)))))) + (zip-acc lsts))) + + ;;; hash-table functions. @@ -188,4 +193,14 @@ value :b, and :c stores the value :d. m)) +(defun copy-hash-table (ht) + (let ((copied (make-hash-table :equal #'equal))) + (maphash (lambda (k v) + (sethash k v copied)) + ht) + copied)) + ;; (defun ,ctor (&key ,@(append (inherited-slots supers) + ;; slots)) + ;; (make-instance (find-class ,name t nil) + ;; ,@(flatten (build-arg-list all-slots)))) diff --git a/package.lisp b/package.lisp index 2fe3782..ab03a7c 100644 --- a/package.lisp +++ b/package.lisp @@ -15,6 +15,7 @@ #:mksymb #:mkkw #:defclass! + #:zip #:enable-hash-table-reader #:hashkeys #:sethash