If item not in the lst in scheme
- by ms. sakura
I'm working on context-free grammars, and I have a function that returns the (terminal values of grammar)
for example:
i have non-terminal function that results in (A B) , from calling say ((A cat) (B happy np) (A B sad))
so technically A and B are non terminals of the grammar. Now I want to be able to get the terminals (cat happy np sad)
(define terminals
(lambda (lsts)
(cond
((null? lsts) lsts)
((not(member? (car(car lsts)) (n-terminals lsts)))
(cons (car(car lsts)) (terminals (car (cdr lsts)))))
(else (terminals (cdr lsts))))))
PS: functionality of n-terminals is described above.
member? is a boolean function that returns true if an item is a member of the list, false otherwise.
My function returns an empty lst. What am I missing here?