fc378d24dd2f default tip

Make zdd union a bit cleaner
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 30 May 2017 15:13:42 +0000
parents 490f2915466f
children (none)
branches/tags default tip
files src/zdd.lisp

Changes

--- a/src/zdd.lisp	Thu May 25 15:49:38 2017 +0000
+++ b/src/zdd.lisp	Tue May 30 15:13:42 2017 +0000
@@ -118,19 +118,24 @@
 
 
 (defun-ematch* zdd-union% (a b)
-  (((node) (sink)) (zdd-union% b a))
+  ((a (sink nil)) a)
+  (((sink nil) b) b)
 
-  (((sink nil) b) b)
+  ((a (sink t)) (unit-patch a))
   (((sink t) b) (unit-patch b))
 
   (((node var-a hi-a lo-a)
     (node var-b hi-b lo-b))
    (cond
-     ((< var-a var-b) (zdd-node var-a hi-a (zdd-union% lo-a b)))
-     ((> var-a var-b) (zdd-node var-b hi-b (zdd-union% lo-b a)))
-     ((= var-a var-b) (zdd-node var-a
-                                (zdd-union% hi-a hi-b)
-                                (zdd-union% lo-a lo-b))))))
+     ((< var-a var-b)
+      (zdd-node var-a hi-a (zdd-union% lo-a b)))
+     ((> var-a var-b)
+      (zdd-node var-b hi-b (zdd-union% lo-b a)))
+     ((= var-a var-b)
+      (zdd-node var-a
+                (zdd-union% hi-a hi-b)
+                (zdd-union% lo-a lo-b))))))
+
 (defun zdd-union (&rest zdds)
   "Return the union of ZDDs: {α | α ∈ Z₁ or α ∈ Z₂}."
   (if zdds