match-expr   scheme


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

Implementation

(define match-expr
  (lambda (e em)
    ;; (println 'match-expr e 'em em)
    (let ((var (variable-constructor em)))
      (if (and (list? var) (not (null? var)) (not (string=? "literal" (cadddr var))))
          (match-check-variable e var)
          (cond ((symbol? e) (match-symbol e em))
                ((string? e) (match-string e em))
                ((number? e) (match-number e em))
                ((vector? e) (match-vector e em))
                ((list? e) (let ((res (match-list e em)))
                             (if (list? res)
                                 (flatten res)
                                 (list res))))
                ((pair? e) (match-pair e em))
                (else MATCH-FAILED))))))


Back to Index