Skip to content

Instantly share code, notes, and snippets.

@fffej
Created June 23, 2009 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fffej/134503 to your computer and use it in GitHub Desktop.
Save fffej/134503 to your computer and use it in GitHub Desktop.
(deftest test-pattern-matching
(is (= fail (pat-match '(i need a ?X) '(i really need a vacation))))
(is (= no-bindings (pat-match '(this is easy) '(this is easy))))
(is (= fail (pat-match '(?X is ?X) '((2 + 2 is 4)))))
(is (= '{?X (2 + 2)} (pat-match '(?X is ?X) '((2 + 2) is (2 + 2)))))
(is (= '{?P (Mr Hulot and I) ?X (a vacation)} (pat-match '((?* ?P) need (?* ?X))
'(Mr Hulot and I need a vacation))))
(is (= '{?X (1 2 a b)} (pat-match '((?* ?X) a b (?* ?X)) '(1 2 a b a b 1 2 a b)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment