On this page:
unify

2.3 equation-style-unifier🔗

 (require sicm/general/equation-style-unifier)
  package: rktsicm

procedure

(unify template expr)  (or/c #f (listof (list symbol? any/c)))

  template : x-expr
  expr : x-expr
This module provides match-like unify procedure. It check if the (symbolic) expression can be matched against the template. Template variables can match a single item: (? id). Or they can match multiple items (?? id). If the same id is used more than once, it needs to match objects that are equal? A third option can be given to the template variables that acts as a guard: (? id guard).

Examples:
> (unify '(1) '(2))

#f

> (unify '(1 (vector 2)) '(1 (vector 2)))

'()

> (unify '(+ (? a) (? a)) '(+ 2 3))

#f

> (unify '(+ (? a) (? a)) '(+ 2 2))

'((a 2 ?))

> (unify '(+ (? a) (* (?? b) (? a))) '(+ 2 (* 3 4 5 6 2)))

'((b (3 4 5 6) ??) (a 2))

> (unify '(+ (? a) (? a)) (list '+ (vector 2) (vector 2)))

'((a #(2) ?))

> (unify `(+ (? a ,even?) (?? b ,(λ (l) (andmap odd? l)))) '(+ 2 3 5))

'((b (3 5) ??) (a 2))