p:if-matches   scheme


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

Implementation

;; @ignore
;; Matches a pattern on datum, and calls consequent-thunk with the match result
;; if the pattern matches, or alternative-thunk with no arguments if it does not.
(define (p:if-matches pattern datum consequent-thunk alternative-thunk)
  (let ((match-result (p:match pattern datum)))
    (cond (match-result ; match succeeded!
           (consequent-thunk match-result))
          (else (alternative-thunk)))))


Back to Index