[plt-scheme] Iterating through days of the week

From: YC (yinso.chen at gmail.com)
Date: Wed May 2 01:01:38 EDT 2007

Hi -

a good starting point for loop construct is -


Which talks about the usage of do and named let.

I also find Jens' eager comprehension informative -


If you have a list, then even map or fold can work for you:

> (map
  (lambda (x y)
    (display y))
  '(0 1 2 3 4 5 6) ; value of i
  '(Sun Mon Tue Wed Thu Fri Sat)) ; index

SunMonTueWedThuFriSat(#<void> #<void> #<void> #<void> #<void> #<void>

The example probably doesn't fit your needs - but hopefully the idea is

On 5/1/07, SpinyNorman <jmcaxolotl at gmail.com> wrote:
> I see that there is a standard way of getting date info such that
> Sunday through Saturday are days 0 through 6.  I want to generate text
> for a week's worth of days.  The part I am not clear on is how the
> iteration should work.  I *think* the relevant control word is "do".
> But of course, the HelpDesk isn't incredibly helpful when you search
> for "do" -- it complains of too many matches.  "(do" gives too few.
> While I was looking up "begin," I did see some pretty good doc on
> "do," but it looks as if it allows for some very sophisticated
> variations, whereas I need something really basic -- just count up
> from zero, use the index for a calculation, and when you get to seven
> (or after passing six), stop.  Also, some of the other functions used
> in the "do" examples are not yet familiar to me.
> Or should I use letrec?
> Please feel free to point me at the appropriate place in the
> embarassment-of-courseware-riches.
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070501/121ac587/attachment.html>

Posted on the users mailing list.