[racket] HtDP, andmap & ormap

From: Bill Richter (richter at math.northwestern.edu)
Date: Mon Oct 4 21:59:10 EDT 2010

Sorry, Matthias, that was dumb of me to post my solution.  What should
I have done?  Should I have just asserted there was no real use of
ormap & andmap in HtDP?  Should I have said that that exercise didn't
IMO require andmap?  Should I not have discussed the exercise at all?
Is this even a good list to ask questions about good program design?

David, I didn't understand what your code was supposed to show.
That's good you know how to replicate draw.ss in universe.  I thought
about doing it, as the docs point you that way, but didn't see how.
Why do you think that HtDP's ormap is different from Racket's ormap?

HtDP Figure 57:
;; ormap : (X  ->  boolean) (listof X)  ->  boolean
;; to determine whether p holds for at least one item on alox
;; that is, (ormap p (list x-1 ... x-n)) = (or (p x-1) (or ... (p x-n)))

That's the ormap described when you hit:
ormap provided from racket/base, racket

Now that's a bit different from what's described when you hit:
ormap  provided from lang/htdp-advanced
(ormap p (list x-1 ... x-n)) = (or (p x-1) ... (p x-n))

I assume that's a documentation bug, as Advanced Student has set!, so
it matters if you evaluate all the later (p x-i)s after you get a
non-#f value.  I should try it out to be sure.


Posted on the users mailing list.