On this page:
eq?
equal?
Version: 4.2.0.5

19 Match utilities

 (require (planet untyped/unlib/match))

Additional patterns for use in scheme/match expressions like match and match-lambda.

(eq? expr pattern ...)

Binds values that are eq? to expr. Behaves similarly to the built-in ? pattern: if the eq? pattern matches, the other patterns are also matched against the same value.

Examples:

  > (define x 123)
  > (define eq-to-x?
      (match-lambda
        [(eq? x y)
         (format "yes: ~a" y)]
        [_ "no"]))
  > (eq-to-x? 123)

  "yes: 123"

  > (eq-to-x? 234)

  "no"

(equal? expr pattern ...)

Binds values that are equal? to expr. Behaves similarly to the built-in ? pattern: if the equal? pattern matches, the other patterns are also matched against the same value.

Examples:

  > (define x "123")
  > (define equal-to-x?
      (match-lambda
        [(equal? x y)
         (format "yes: ~a" y)]
        [_ "no"]))
  > (equal-to-x? "123")

  "yes: 123"

  > (equal-to-x? "456")

  "no"