
wanpeebaw
2020-8-21 08:37:07
Can I apply and/or to a list? If not, what can I do to get similar result?

laurent.orseau
2020-8-21 08:42:25
andmap, ormap

laurent.orseau
2020-8-21 08:42:37
or for/or, for/and

laurent.orseau
2020-8-21 08:43:46
or turn your list into syntax, insert and/or, and evaluate :stuck_out_tongue: (don’t do that)

laurent.orseau
2020-8-21 08:45:27
Note that andmap and for/and behave differently regarding list lengths if you apply them to more than one list

notjack
2020-8-21 08:46:23
transducers version, for my own amusement: (transduce sequence #:into (into-all-match? predicate))
(like (andmap predicate sequence)
but works with any sequence)

laurent.orseau
2020-8-21 08:51:14
if your list is a list of boolean values (or are interpreted as such), then (andmap values my-list)
does the job. You can use identity
instead of values
.

laurent.orseau
2020-8-21 08:54:13
Otherwise (untested): (define (and-proc . vals)
(or (empty? vals) (and (first vals) (and-proc (rest vals)))))