Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; ** collect-prop-variables **
- ;; This function collects the variables of a logical formula from a given list
- (define collect-prop-variables
- (lambda (l)
- (cond
- ;; If the list is null, we've gone through everything so return an empty list
- ((null? l) `())
- ;; If the first item in the list is an atom...
- ((atom? (car l))
- (cond
- ;; If it's not a logical operator, keep it and keep going through the rest of the list
- ((eq? (operator? (car l)) #f) (flatten (cons (car l) (collect-prop-variables (cdr l)))))
- ;; Otherwise, ignore it and keep going through the list
- (else (collect-prop-variables (cdr l)))
- )
- )
- ;; If the first item is a list recurse through it and through the rest of the list
- (else (remove-duplicates (flatten (cons (collect-prop-variables (car l)) (collect-prop-variables (cdr l)))))))))
Add Comment
Please, Sign In to add comment