|
|
|
@ -11,7 +11,7 @@
|
|
|
|
|
stack ; we've got an incomplete chunk. return the stack
|
|
|
|
|
(let ([x (first input)] [xs (rest input)]) ; grab the first element of the input
|
|
|
|
|
(if (member x opening) ; if it is an opening bracket
|
|
|
|
|
(go xs (cons x stack)) ; push it on the stack
|
|
|
|
|
(go xs (cons x stack)) ; push it on the stack and recurse
|
|
|
|
|
(let* ([y (first stack)] ; otherwise, it's a closing bracket. grab the top of the stack..
|
|
|
|
|
[matching (second (assoc y pairs))]) ; and find its matching closing bracket
|
|
|
|
|
(if (equal? matching x) ; if they match..
|
|
|
|
|