Suppose we have a list of pairs, ex. '((a . true) (b . false))
How do I declare it within a function and use the variable to do something else? (say using it to evaluate boolean expressions like (a and b)
)
Currently I have
(define foo2
(λ (xs)
(let ((car (first xs)) (cdr (first xs)))
xs)
(eval (and (car (first xs)) ; check a is #t
#t)
)))
which works for when a list consists of a single element, example:
> (foo2 '((a . true)))
#t
but I want it to recursively (or other methods) to take in multiple variables like '((a . true) (b . false))
.
I tried the usual way like
(cons
(eval (and (car (first xs)) #t))
(foo2 (rest xs)))
but does not work as wanted.
And is this possible?
(define foo3
(λ (xs)
(let ((car (first xs)) (cdr (first xs)))
xs)
(eval (and a #t)))) ; a is what we defined to be #t