impc:ti:nativef-poly-check-match-ftypes   scheme


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

Implementation

(define impc:ti:nativef-poly-check-match-ftypes
  (lambda (args ftypes request?)
    (let* ((ftypes2 (cl:remove-if (lambda (x) (<> (length (cddr x)) (length args))) ftypes))
           (results (map (lambda (type)
                           (map (lambda (ct ft) ;; check args aginst ftype
                                  (if (and (number? ct) (number? ft))
                                      (if (= ct ft) #t #f)
                                      (if (and (string? ct) (string? ft))
                                          (if (string=? ct ft) #t #f)
                                          (if (list? ct)
                                              (if (member ft ct) #t #f) ;; #f
                                              #f))))
                                (if request?
                                    (cons request? args)
                                    args)
                                (if request?
                                    (cdr type)
                                    (cddr type))))
                         ftypes2))
           (hits (map (lambda (r) (length (cl:remove #f r))) results))
           (best (if (null? hits) 0 (apply max hits)))
           (res-types (map (lambda (x y) (cons x y)) (if (null? hits) (make-list (length ftypes2) 0) hits) ftypes2))
           (short-list (cl:remove-if (lambda (x) (<> (car x) best)) res-types))
           (valid (map (lambda (x) (cdr x)) short-list)))
      valid)))


Back to Index