What is the reason for not offering a looping construct in racket? For
example, something like:
(loop (i 1 10) (print i))
Just for the masses, it seems simpler to use.
Any comments?
_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users
http://docs.racket-lang.org/guide/for.html
Robby
Anyway, for the benefit of anyone new to syntax extensions, here is a
syntax definition that supports the "for-loop" example (warning: it
doesn't error-check as much as it should, because that would clutter the
example). You can paste this into DrRacket and use the Macro Stepper to
watch how it expands.
#lang scheme/base
(define-syntax for-loop
(syntax-rules ()
((_ (VAR START END) BODY0 BODY1 ...)
(let ((end-val END))
(let loop ((VAR START))
(if (> VAR end-val)
(void)
(begin BODY0 BODY1 ...
(loop (add1 VAR)))))))))
(for-loop (i 1 10) (print i))
Robby Findler wrote at 06/27/2010 09:34 PM:
> Please see 'for' in the docs. Here's the relevant section of the Guide:
>
> http://docs.racket-lang.org/guide/for.html
>
> Robby
>
> On Sun, Jun 27, 2010 at 8:32 PM, Brad Long <br...@longbrothers.net> wrote:
>
>> Dear racketeers,
>>
>> What is the reason for not offering a looping construct in racket? For
>> example, something like:
>>
>> (loop (i 1 10) (print i))
>>
>> Just for the masses, it seems simpler to use.
>>
>> Any comments?
>>
--
http://www.neilvandyke.org/
> Dear racketeers,
>
> What is the reason for not offering a looping construct in racket? For example, something like:
>
> (loop (i 1 10) (print i))
>
It's there:
(for/list ([i (in-range 1 10)]) i)
prints out
'(1 2 3 4 5 6 7 8 9)
... also, note that 'for/list' contains no opiates.
John
What is the reason for not offering a looping construct in racket? Forexample, something like:(loop (i 1 10) (print i))Just for the masses, it seems simpler to use.