Skip to content

Instantly share code, notes, and snippets.

@apg
Created September 8, 2011 12:46
Show Gist options
  • Save apg/1203317 to your computer and use it in GitHub Desktop.
Save apg/1203317 to your computer and use it in GitHub Desktop.
(define (match pat thing)
(cond
((null? pat) 'yes)
((null? thing) 'no)
((eq? (car pat) '*) (match (cdr pat) (cdr thing)))
((eq? (car pat) '**) (match (cdr pat) (cdr thing)))
((eq? (car pat) (car thing)) (match (cdr pat) (cdr thing)))
(else 'no)))
(match '(* y z) '(z y z))
(match-until 'y '(z y z))
-> = y z, false, collect z
-> = y y, true, return collected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment