ax-of-a   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/core/pattern.xtm

Implementation

;; axiom of association
(define ax-of-a
  (lambda (expr)
    (let* ((pat1 (match '((p? = q?) = r?)))
           (pat2 (match '(p? = (q? = r?)))) 
           (res1 (pat1 expr))
           (res2 (pat2 expr))
           (res (if res1 res1 (if res2 res2 '()))))
      (if (or (not res) (null? res)) 
          #f
          (let ((p (mkey "p" res))
                (q (mkey "q" res))
                (r (mkey "r" res)))
              `(,(car p) = ,(car q) = ,(car r)))))))


Back to Index