(defun returnFirstCharacter(p)
(if (symbolp p) (char (symbol-name p) 0) nil)
)
(defun returnRestCharacters (p)
(let ()
(intern (subseq(string p) 1))
)
)
(defun val (x a)
(cond ((null a) nil)
((equal (car(cdr a)) x) (cdr (cdar a)))
(t (val x (cdr a)))
)
)
(defun match (pattern data)
(cond
((equal pattern data) t)
((match2 pattern data nil))
(t nil)
)
)
(defun match2 (p d a)
(cond
( (null p)(cond
((null a) t)
(t a)
)
)
((numberp p) (cond
((equal p d) t)
(t nil)
)
)
( (symbolp p) (cond
((alpha-char-p (returnFirstCharacter p))
(let ()(if (equal p d) (match2 nil nil a) nil)))
((equal (returnFirstCharacter p) #\=)
(let ()
(if (and (returnRestCharacters p) (null (val (returnRestCharacters p) a)))
(match2 nil nil (cons (
list = (returnRestCharacters p) d) a)
)
(let ()
(if (and (returnRestCharacters p) (equal (val (returnRestCharacters p) a) (car d)))
(match2 (cdr p) (cdr d) a) nil)
)
)
)
)
)
)
( (listp p)
(cond
((equal (list-length p) (list-length d))
(let ()
( if (equal p d)
(match2 nil nil a)
(let ()
(append (match2 (car p) (car d) a)(match2 (cdr p) (cdr d) a) )
)
)
)
)
)
)
)
)
I have match2 being called twice by itself.I want the recursive calls to happen. the moment a call of match2 returns either true or nil the program is terminated i want control to be passed back to the previous match2 which called it.
As you can see I have called match2 twice. (listp p) this condiiton in match2 I need to do recursion.How to do this