[racket] HtDP, andmap & ormap

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Oct 4 22:05:18 EDT 2010

Yes, an assertion would have been fine. You're right. 

I am hoping to write up a revised Part IV by the end of this 
semester. It will show how to teach the use of 'loops' (*map)
via type-based selection. I don't have time to spell it all 
out in email first. -- Matthias



On Oct 4, 2010, at 9:59 PM, Bill Richter wrote:

> 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.