be318e37013f — Leonard Ritter tip 3 months ago
* BDD: small improvement
2 files changed, 58 insertions(+), 4 deletions(-)

M testing/BDD.sc
M testing/tukdag.sc
M testing/BDD.sc +56 -2
@@ 32,6 32,42 @@ type+ T
                 returning bool
                 self as Ternary == other as Ternary
 
+    @@ memo
+    inline __< (cls T)
+        static-if (cls == T)
+            fn (self other)
+                returning bool
+                dispatch self
+                case Zero ()
+                    dispatch other
+                    case Zero () false
+                    default true
+                case One ()
+                    dispatch other
+                    case Zero () false
+                    case One () false
+                    default true
+                case Var (name)
+                    dispatch other
+                    case Zero () false
+                    case One () false
+                    case Var (name2) (name as string < name2 as string)
+                    default true
+                case Term (x y z)
+                    dispatch other
+                    case Zero () false
+                    case One () false
+                    case Var (name2) false
+                    case Term (u v w)
+                        if (x == u)
+                            if (y == v)
+                                if (z == w) false
+                                else (z < w)
+                            else (y < v)
+                        else (x < u)
+                    default true
+                default false
+
     fn make-term
 
     fn sub (self key value)

          
@@ 205,6 241,16 @@ type+ T
                         this-function b
                         (default-styler 'style-operator ")")
             default;
+            if (c == (~ b))
+                return
+                    ..
+                        (default-styler 'style-operator "(")
+                        this-function a
+                        " "
+                        (default-styler 'style-operator "^")
+                        " "
+                        this-function b
+                        (default-styler 'style-operator ")")
             return
                 ..
                     (default-styler 'style-operator "(?")

          
@@ 216,7 262,7 @@ type+ T
                     this-function b
                     (default-styler 'style-operator ")")
         default
-            "???"
+            str"???"
 
 
     fn __repr (self)

          
@@ 231,7 277,7 @@ type+ T
                 \ (repr a) " " (repr b) " " (repr c)
                 (default-styler 'style-operator ")")
         default
-            "?"
+            str"?"
 
 type+ T
     inline... substitute (self keys...)

          
@@ 352,6 398,14 @@ print
             #rev& b0 b1 b2 n3
             #rev& b0 b1 b2 b3
 
+do
+    let a b c d = (T 'a) (T 'b) (T 'c) (T 'd)
+    let ~a ~b ~c ~d = (~ a) (~ b) (~ c) (~ d)
+    print
+        T.bool-repr
+            ~a & b & ~c & d | a & b & ~c & ~d | ~a & b & c & ~d | ~a & ~b & ~c & d
+        #~a & b & ~c & d | a & b & ~c & ~d | ~a & b & c & ~d | ~a & ~b & ~c & d
+        #| (& ~a b ~c d) (& a b ~c ~d) (& ~a b c ~d) (& ~a ~b ~c d)
 
 #
     if a

          
M testing/tukdag.sc +2 -2
@@ 254,8 254,8 @@ inline gen-level2-test-geometry ()
                         ftou (fmul v (utof TS))
                     fetch cube_texture (uvec2 u v)
                 let tex =
-                    #hardcube u v
-                    softcube u v
+                    hardcube u v
+                    #softcube u v
                 inline tform (x)
                     fmul (fadd (fmul x (fconst 0.5)) (fconst 0.5)) tex
                 let r = (tform r)