match-check-variable-predicates   scheme


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

Implementation

(define match-check-variable-predicates
  (lambda (e var)
    (let ((predicate (cadddr var))
          (matchtype (cadr var))
          (expr e))
      (cond ((string=? predicate "list") (list? expr))
            ((string=? predicate "number") (number? expr))
            ((string=? predicate "atom") (atom? expr))
            ((string=? predicate "pair") (pair? expr))
            ((string=? predicate "symbol") (symbol? expr))
            ((string=? predicate "string") (string? expr))
            ((string=? predicate "defined") (defined? expr))
            ((string=? predicate "") #t)
            ((and (defined? (string->symbol predicate))
                  (closure? (eval (string->symbol predicate)))) ((eval (string->symbol predicate)) expr))
            (else #f)))))


Back to Index