From: Gary King Date: Sun, 28 Sep 2008 19:30:47 +0000 (-0400) Subject: Removed the need for metabang-bind X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=000a31e8bb29016b2f5c6f41146bca3385cecf99;p=cl-graph.git Removed the need for metabang-bind darcs-hash:20080928193047-3cc5d-354e6a26765a3b39e54893974791f2270d40e8cb.gz --- diff --git a/cl-graph.asd b/cl-graph.asd index 2f93908..c13b272 100644 --- a/cl-graph.asd +++ b/cl-graph.asd @@ -51,8 +51,7 @@ instructions.")) (intern (symbol-name '#:run-tests) :lift) :config :generic)) :depends-on ((:version :metatilities-base "0.6.0") - :cl-containers - :metabang-bind + (:version :cl-containers "0.11.0") )) (defmethod operation-done-p diff --git a/dev/graph-algorithms.lisp b/dev/graph-algorithms.lisp index bd52fca..3280fff 100644 --- a/dev/graph-algorithms.lisp +++ b/dev/graph-algorithms.lisp @@ -211,8 +211,8 @@ (iterate-elements edges (lambda (edge) - (bind ((v1 (element (source-vertex edge))) - (v2 (element (target-vertex edge)))) + (let ((v1 (element (source-vertex edge))) + (v2 (element (target-vertex edge)))) (add-edge-between-vertexes graph v1 v2 :edge-class (type-of edge) :edge-type (if (directed-edge-p edge) @@ -240,14 +240,14 @@ (defmethod minimum-spanning-tree ((graph basic-graph) &key (edge-sorter #'edge-lessp-by-weight)) - (bind ((result nil)) + (let ((result nil)) (iterate-vertexes graph (lambda (v) (mst-make-set v))) (loop for edge in (sort (edges graph) edge-sorter) do - (bind ((v1 (source-vertex edge)) + (let ((v1 (source-vertex edge)) (v2 (target-vertex edge))) (unless (eq (mst-find-set v1) @@ -266,7 +266,7 @@ (defmethod minimum-spanning-tree ((vertex-list list) &key (edge-sorter #'edge-lessp-by-weight)) - (bind ((result nil) + (let ((result nil) (v-edges (remove-duplicates (flatten (mapcar #'edges vertex-list)) :test #'eq))) @@ -276,10 +276,10 @@ (mst-make-set v))) (loop for edge in (sort v-edges edge-sorter) do - (bind ((v1 (source-vertex edge)) - (v2 (target-vertex edge)) - (v1-set (mst-find-set v1)) - (v2-set (mst-find-set v2))) + (let ((v1 (source-vertex edge)) + (v2 (target-vertex edge)) + (v1-set (mst-find-set v1)) + (v2-set (mst-find-set v2))) (when (or (not v1-set) (not v2-set)) @@ -308,7 +308,7 @@ ;;; --------------------------------------------------------------------------- #+test -(bind ((g (make-container 'graph-container))) +(let ((g (make-container 'graph-container))) (add-edge-between-vertexes g :v :y :edge-type :directed) (add-edge-between-vertexes g :u :x :edge-type :directed) (add-edge-between-vertexes g :x :v :edge-type :directed) @@ -457,7 +457,7 @@ (edges u) :filter (lambda (e) (out-edge-for-vertex-p e u))) sorter) do - (bind ((v (other-vertex edge u))) + (let ((v (other-vertex edge u))) (unless (color edge) (setf (color edge) (color v))) @@ -477,7 +477,7 @@ ;;; --------------------------------------------------------------------------- #+test -(bind ((g (make-container 'graph-container))) +(let ((g (make-container 'graph-container))) (add-edge-between-vertexes g :v :y :edge-type :directed) (add-edge-between-vertexes g :u :x :edge-type :directed) (add-edge-between-vertexes g :x :v :edge-type :directed) @@ -548,7 +548,7 @@ ;;; --------------------------------------------------------------------------- (defmethod map-over-all-combinations-of-k-vertexes ((graph basic-graph) k fn) - (bind ((vertex-count (size graph)) + (let* ((vertex-count (size graph)) (symbols (make-list k :initial-element vertex-count)) (vertexes (vertexes graph))) (iterate-over-indexes @@ -562,7 +562,7 @@ ;;; --------------------------------------------------------------------------- #+test -(bind ((result nil) +(let ((result nil) (g (make-container 'graph-container))) (add-edge-between-vertexes g :u :v :edge-type :directed) (add-edge-between-vertexes g :u :x :edge-type :directed) @@ -576,7 +576,7 @@ g 4 (lambda (vertex-list) - (bind ((graph-from-vertexes (make-graph-from-vertexes vertex-list))) + (let ((graph-from-vertexes (make-graph-from-vertexes vertex-list))) (when (mst-kruskal graph-from-vertexes #'identity-sorter) (push graph-from-vertexes result))))) result) @@ -587,7 +587,7 @@ ;;; --------------------------------------------------------------------------- (defmethod map-over-all-combinations-of-k-edges ((graph basic-graph) k fn) - (bind ((edge-count (edge-count graph)) + (let* ((edge-count (edge-count graph)) (symbols (make-list k :initial-element edge-count)) (edges (edges graph))) (print symbols) @@ -602,10 +602,10 @@ ;;; --------------------------------------------------------------------------- (defmethod map-over-all-combinations-of-k-edges ((vertex basic-vertex) k fn) - (bind ((edge-count (edge-count vertex)) - (symbols (make-list k :initial-element edge-count)) - (edges (edges vertex))) - (print symbols) + (let* ((edge-count (edge-count vertex)) + (symbols (make-list k :initial-element edge-count)) + (edges (edges vertex))) + ;(print symbols) (iterate-over-indexes symbols (lambda (edge-indexes) diff --git a/dev/graph-container.lisp b/dev/graph-container.lisp index 21ca52e..1e24d33 100644 --- a/dev/graph-container.lisp +++ b/dev/graph-container.lisp @@ -149,7 +149,7 @@ DISCUSSION &key force-new?) (declare (ignore force-new?)) - (bind ((vertex-1 (vertex-1 edge)) + (let ((vertex-1 (vertex-1 edge)) (vertex-2 (vertex-2 edge))) (cond ((eq vertex-1 vertex-2) @@ -209,7 +209,7 @@ DISCUSSION (value-2 t) fn &key error-if-not-found?) - (bind ((v1 (find-vertex graph value-1 error-if-not-found?)) + (let ((v1 (find-vertex graph value-1 error-if-not-found?)) (v2 (find-vertex graph value-2 error-if-not-found?))) (or (and v1 v2 (find-edge-between-vertexes-if graph v1 v2 fn)) (when error-if-not-found? diff --git a/dev/graph-generation.lisp b/dev/graph-generation.lisp index eed4009..ee5b9d3 100644 --- a/dev/graph-generation.lisp +++ b/dev/graph-generation.lisp @@ -560,7 +560,7 @@ from this distribution (defun generate-girvan-newman-graph (generator graph-class z-in) (warn "This is broken!") - (bind ((g (make-instance graph-class)) + (let ((g (make-instance graph-class)) (group-count 4) (group-size 32) (edge-count 16) @@ -589,7 +589,7 @@ from this distribution (check-type from-group fixnum) (loop - (bind ((other-group (integer-random generator 0 (- group-count 2))) + (let ((other-group (integer-random generator 0 (- group-count 2))) (other (sample-element (item-at groups (if (= from-group other-group) (1+ other-group) @@ -662,7 +662,7 @@ from this distribution (iterate-edges g (lambda (e) - (bind ((v1 (vertex-1 e)) + (let ((v1 (vertex-1 e)) (v2 (vertex-2 e)) (id1 (element v1)) (id2 (element v2))) @@ -752,7 +752,7 @@ from this distribution (list vertex other-kind)))) (update (kind thing) ;; handle bookkeeping for changed vertex degree - (bind ((sampler (aref vertex-sampler kind)) + (let ((sampler (aref vertex-sampler kind)) (node (find-node sampler thing))) (delete-node sampler node) (insert-item sampler thing)))) @@ -1231,7 +1231,7 @@ Split into a function to compute some of the intermediate pieces and one to use (flet ((sample-edges-for-vertex (vertex) ;(spy vertex) (loop repeat (item-at-1 vertex-degrees vertex) do - (bind (((edge-kind . edge) (delete-last edge-sampler))) + (let (((edge-kind . edge) (delete-last edge-sampler))) (ecase edge-kind (:source (setf (first edge) vertex)) (:target (setf (second edge) vertex))))))) @@ -1315,7 +1315,7 @@ should include pointer back to original graph ;;; --------------------------------------------------------------------------- (defmethod initialize-instance :after ((object weighted-edge-sampler) &key) - (bind ((generator (generator object)) + (let ((generator (generator object)) (weighted-edge-count (let ((result 0)) (iterate-edges (graph object) (lambda (e) (incf result (weight e)))) @@ -1439,10 +1439,10 @@ should include pointer back to original graph (defmethod generate-simple-preferential-attachment-graph (generator graph size minimum-degree) - (bind ((m (make-array (list (* 2 size minimum-degree))))) + (let ((m (make-array (list (* 2 size minimum-degree))))) (loop for v from 0 to (1- size) do (loop for i from 0 to (1- minimum-degree) do - (bind ((index (* 2 (+ i (* v minimum-degree)))) + (let ((index (* 2 (+ i (* v minimum-degree)))) (r (integer-random generator 0 index))) (setf (item-at m index) v (item-at m (1+ index)) (item-at m r))))) @@ -1487,7 +1487,7 @@ should include pointer back to original graph assortativity-matrix &key (vertex-labeler 'simple-group-id-generator) (duplicate-edge-function :ignore)) - (bind ((kind-count (array-dimension kind-matrix 0)) + (let ((kind-count (array-dimension kind-matrix 0)) (vertex-kinds (sample-vertexes-for-mixed-graph generator size kind-matrix)) (vertex-kind-counts (element-counts vertex-kinds :sort #'< :sort-on :values)) (edge-recorders (make-array (list kind-count))) @@ -1506,9 +1506,9 @@ should include pointer back to original graph ;; add vertexes (to ensure that we have something at which to point) (loop for v from 0 to (1- size) for kind in vertex-kinds do - (bind ((edge-recorder (aref edge-recorders kind))) + (let ((edge-recorder (aref edge-recorders kind))) (loop for i from 0 to (1- minimum-degree) do - (bind ((index (* 2 (+ i (* (aref count-recorders kind) minimum-degree))))) + (let ((index (* 2 (+ i (* (aref count-recorders kind) minimum-degree))))) (setf (item-at edge-recorder index) (funcall vertex-labeler kind v))))) (incf (aref count-recorders kind))) @@ -1518,10 +1518,10 @@ should include pointer back to original graph (setf (aref count-recorders i) 0)) (loop for v from 0 to (1- size) for kind in vertex-kinds do - (bind ((edge-recorder (aref edge-recorders kind)) + (let ((edge-recorder (aref edge-recorders kind)) (edge-sampler (aref edge-samplers kind))) (loop for i from 0 to (1- minimum-degree) do - (bind ((index (* 2 (+ i (* (aref count-recorders kind) minimum-degree)))) + (let ((index (* 2 (+ i (* (aref count-recorders kind) minimum-degree)))) (other-kind (funcall edge-sampler)) (other-index (* 2 (+ i (* (min (1- (item-at vertex-kind-counts other-kind)) (aref count-recorders other-kind)) @@ -1556,7 +1556,7 @@ should include pointer back to original graph (loop for vertex across (aref edge-recorders kind) for index = 0 then (1+ index) when (consp vertex) do - (bind (((other-kind other-index) vertex)) + (let (((other-kind other-index) vertex)) #+Ignore (when-debugging-format generate-preferential-attachment-graph "~2D ~10D, ~A -> ~A" @@ -1701,7 +1701,7 @@ should include pointer back to original graph (defun add-acquaintance-and-maybe-kill-something (generator graph death-probability duplicate-edge-function) ;; add edges step - (bind ((vertex (sample-element (graph-vertexes graph) generator)) + (let ((vertex (sample-element (graph-vertexes graph) generator)) (neighbors (when (>= (size (vertex-edges vertex)) 2) (sample-unique-elements (vertex-edges vertex) generator 2)))) diff --git a/dev/graph-metrics.lisp b/dev/graph-metrics.lisp index 066781d..95dfe8a 100644 --- a/dev/graph-metrics.lisp +++ b/dev/graph-metrics.lisp @@ -74,7 +74,7 @@ DISCUSSION &key (edge-size (constantly 1))) "Prints a summary of vertex degrees in `graph` to standard-out. Both the average degree of all vertexes and the average degree between all pairs of vertex classes \(as determined by the vertex-classifier\) will be printed. The `edge-size` parameter is passed on to `vertex-degree` to allow for weighted edges." - (bind ((counts (node-counts graph :key vertex-classifier)) + (let ((counts (node-counts graph :key vertex-classifier)) (kinds (collect-elements counts :transform #'first))) (format t "~%Vertex counts: ") (loop for (kind count) in counts do diff --git a/dev/graph.lisp b/dev/graph.lisp index 2625aab..98049a7 100644 --- a/dev/graph.lisp +++ b/dev/graph.lisp @@ -1029,7 +1029,7 @@ length" (defun map-shortest-paths (graph start-vertex depth fn &key (filter (constantly t))) "Apply fn to each shortest path starting at `start-vertex` of depth `depth`. The `filter` predicate is used to remove vertexes from consideration." - (bind ((visited (make-container 'simple-associative-container + (let ((visited (make-container 'simple-associative-container :test #'equal))) (labels ((visit (p) (setf (item-at-1 visited p) t)) diff --git a/dev/graphviz/graphviz-support.lisp b/dev/graphviz/graphviz-support.lisp index eda1187..b511279 100644 --- a/dev/graphviz/graphviz-support.lisp +++ b/dev/graphviz/graphviz-support.lisp @@ -352,7 +352,7 @@ B--D [] (getf (dot-attributes thing) attr)) (defmacro defpixel-inch-accessors (name attr type) - (bind ((actual-name (form-symbol name "-IN-PIXELS"))) + (let ((actual-name (form-symbol name "-IN-PIXELS"))) `(progn (eval-always (export ',actual-name)) (defmethod ,actual-name ((thing ,type)) diff --git a/dev/package.lisp b/dev/package.lisp index 4775542..b5b03b8 100644 --- a/dev/package.lisp +++ b/dev/package.lisp @@ -10,8 +10,7 @@ DISCUSSION (in-package #:common-lisp-user) (defpackage #:cl-graph - (:use #:common-lisp #:metatilities #:cl-containers - #:metabang.bind #+(or) #:cl-mathstats #+(or) #:moptilities) + (:use #:common-lisp #:metatilities #:cl-containers) (:nicknames #:metabang.graph) (:documentation "CL-Graph is a Common Lisp library for manipulating graphs and running graph algorithms.") diff --git a/unit-tests/test-graph.lisp b/unit-tests/test-graph.lisp index 6e95fe0..1a64abc 100644 --- a/unit-tests/test-graph.lisp +++ b/unit-tests/test-graph.lisp @@ -16,9 +16,9 @@ (addtest (test-test-vertex) test-1 - (metatilities:bind ((x (float 2.1d0)) - (y (float 2.1d0)) - (g (make-container 'graph-container))) + (let ((x (float 2.1d0)) + (y (float 2.1d0)) + (g (make-container 'graph-container))) (add-vertex g (+ x y)) (add-vertex g (+ x y)) @@ -26,7 +26,7 @@ (addtest (test-test-vertex) test-2 - (bind ((x (float 2.1d0)) + (let ((x (float 2.1d0)) (y (float 2.1d0)) (g (make-container 'graph-container :vertex-test #'=))) (add-vertex g (+ x y))