b9b6ba46e47b

Formatting
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Fri, 20 Jan 2017 01:08:00 +0000
parents ddcf7ddf78f6
children 63b7d69e7d8b
branches/tags (none)
files src/chancery.lisp vendor/make-quickutils.lisp vendor/quickutils.lisp

Changes

--- a/src/chancery.lisp	Wed Jan 18 18:04:41 2017 +0000
+++ b/src/chancery.lisp	Fri Jan 20 01:08:00 2017 +0000
@@ -76,15 +76,15 @@
     :total (apply #'+ 0.0 weights)))
 
 
-(defmethod print-object ((wl weightlist) s)
-  (print-unreadable-object (wl s :type t)
+(defmethod print-object ((object weightlist) stream)
+  (print-unreadable-object (object stream :type t)
     (prin1 (mapcar #'list
-                   (weightlist-weights wl)
-                   (weightlist-items wl))
-           s)))
+                   (weightlist-weights object)
+                   (weightlist-items object))
+           stream)))
 
-(defmethod make-load-form ((wl weightlist) &optional environment)
-  (make-load-form-saving-slots wl
+(defmethod make-load-form ((object weightlist) &optional environment)
+  (make-load-form-saving-slots object
                                :slot-names '(weights sums items total)
                                :environment environment))
 
--- a/vendor/make-quickutils.lisp	Wed Jan 18 18:04:41 2017 +0000
+++ b/vendor/make-quickutils.lisp	Fri Jan 20 01:08:00 2017 +0000
@@ -8,6 +8,7 @@
                :ensure-boolean
                :ensure-list
                :flip
+               :hash-table-alist
                :range
                :rcurry
                :riffle
--- a/vendor/quickutils.lisp	Wed Jan 18 18:04:41 2017 +0000
+++ b/vendor/quickutils.lisp	Fri Jan 20 01:08:00 2017 +0000
@@ -2,7 +2,7 @@
 ;;;; See http://quickutil.org for details.
 
 ;;;; To regenerate:
-;;;; (qtlc:save-utils-as "quickutils.lisp" :utilities '(:CURRY :ENSURE-BOOLEAN :ENSURE-LIST :FLIP :RANGE :RCURRY :RIFFLE :SPLIT-SEQUENCE) :ensure-package T :package "CHANCERY.QUICKUTILS")
+;;;; (qtlc:save-utils-as "quickutils.lisp" :utilities '(:CURRY :ENSURE-BOOLEAN :ENSURE-LIST :FLIP :HASH-TABLE-ALIST :RANGE :RCURRY :RIFFLE :SPLIT-SEQUENCE) :ensure-package T :package "CHANCERY.QUICKUTILS")
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (unless (find-package "CHANCERY.QUICKUTILS")
@@ -15,8 +15,8 @@
 (when (boundp '*utilities*)
   (setf *utilities* (union *utilities* '(:MAKE-GENSYM-LIST :ENSURE-FUNCTION
                                          :CURRY :ENSURE-BOOLEAN :ENSURE-LIST
-                                         :FLIP :RANGE :RCURRY :RIFFLE
-                                         :SPLIT-SEQUENCE))))
+                                         :FLIP :HASH-TABLE-ALIST :RANGE :RCURRY
+                                         :RIFFLE :SPLIT-SEQUENCE))))
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (defun make-gensym-list (length &optional (x "G"))
     "Returns a list of `length` gensyms, each generated as if with a call to `make-gensym`,
@@ -79,6 +79,16 @@
         (funcall f x y)))
   
 
+  (defun hash-table-alist (table)
+    "Returns an association list containing the keys and values of hash table
+`table`."
+    (let ((alist nil))
+      (maphash (lambda (k v)
+                 (push (cons k v) alist))
+               table)
+      alist))
+  
+
   (defun range (start end &key (step 1) (key 'identity))
     "Return the list of numbers `n` such that `start <= n < end` and
 `n = start + k*step` for suitable integers `k`. If a function `key` is
@@ -225,7 +235,7 @@
                             sequence start end count remove-empty-subseqs))))
   
 (eval-when (:compile-toplevel :load-toplevel :execute)
-  (export '(curry ensure-boolean ensure-list flip range rcurry riffle
-            split-sequence split-sequence-if split-sequence-if-not)))
+  (export '(curry ensure-boolean ensure-list flip hash-table-alist range rcurry
+            riffle split-sequence split-sequence-if split-sequence-if-not)))
 
 ;;;; END OF quickutils.lisp ;;;;