impc:ti:unify-lists   scheme


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

Implementation

;; this goes through IN ORDER and returns either:
;; NULL if the lists don't match
;; or
(define impc:ti:unify-lists
  (lambda args
                                        ;(println 'unify: args 'norm: (impc:ti:type-normalize args))
    (if (null? args)
        args
        (let ((lgths (map (lambda (k) (length k)) args)))
          (if (not (null? (cl:remove (car lgths) lgths)))
              '()
              (let ((result
                     (apply map (lambda args
                                  (let ((l1 (cl:remove '() args)))
                                    (if (null? l1) l1
                                        (let ((l2 (cl:remove-duplicates l1)))
                                          (if (null? l2)
                                              l2
                                              ;;(car l2))))))
                                              (if (= 1 (length l2))
                                                  (car l2)
                                                  '()))))))
                            args)))
                                        ;(println 'result: result)
                (if (member '() result)
                    '()
                    result)))))))


Back to Index