impc:ir:genericfunc-match-tuple-types   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/llvmti.xtm

Implementation

(define impc:ir:genericfunc-match-tuple-types
  (lambda (a b)
    (let ((t1 (impc:ir:get-pretty-tuple-arg-strings a))
          (t2 (impc:ir:get-pretty-tuple-arg-strings b)))
      (if (<> (length t1) (length t2))
          -1
          (let ((weight (apply +
                               (map (lambda (x y)
                                      (cond ((string=? x "_") 0)
                                            ((string=? x y) 1)
                                            ((string=? y "_") 0)
                                            (else -1)))
                                    t1 t2))))
            (if (> weight 0) weight ;;(/ weight (length t1))
                (if (< weight 0) -1
                    1/4))))))) ;; give some slight weighting (more than 0) just for being a valid tuple


Back to Index