Add procedure-arity-intersection.
authorChris Hanson <org/chris-hanson/cph>
Mon, 8 Jul 2019 19:35:03 +0000 (15:35 -0400)
committerChris Hanson <org/chris-hanson/cph>
Mon, 8 Jul 2019 19:35:23 +0000 (15:35 -0400)
src/runtime/procedure.scm
src/runtime/runtime.pkg

index a4c59a1ff2841418140c77820cf948b2e9a48da2..9482fdbfd75f5eeeaa905572a1e6885ea91e55ae 100644 (file)
@@ -220,6 +220,15 @@ USA.
                (fix:<= (procedure-arity-max arity1)
                        (procedure-arity-max arity2))))))
 
+(define (procedure-arity-intersection a1 a2)
+  (make-procedure-arity (fix:max (procedure-arity-min a1)
+                                (procedure-arity-min a2))
+                        (let ((m1 (procedure-arity-max a1))
+                              (m2 (procedure-arity-max a2)))
+                         (if m1
+                             (if m2 (fix:min m1 m2) m1)
+                             m2))))
+
 (define-integrable (simple-arity? object)
   (index-fixnum? object))
 
index acb35ec2875236434fc211cd15d1f2bcae39f56a..714d247a5b8f24645ef931fcd89690508b38e55f 100644 (file)
@@ -1932,6 +1932,7 @@ USA.
          primitive-procedure-name
          primitive-procedure?
          procedure-arity
+         procedure-arity-intersection
          procedure-arity-max
          procedure-arity-min
          procedure-arity-valid?