[plt-scheme] Outer-inner loops in Scheme?
Do you mean this:
;; Pretty Big
(define (test)
(define range (build-list 10 identity))
(for-each (lambda (x) (for-each (lambda (y) (printf "~a ~a\n" x
y)) range)) range))
-- Matthias
On May 14, 2007, at 9:06 AM, Grant Rettke wrote:
> Hi folks,
>
> Last night I looked at a solution to a programming problem and the
> typical approach was to use an inner and outer loop (think C or Ruby).
> My approach in Scheme was to do something like the following:
>
> (define test
> (λ ()
> (outer-inner-loop 0 0 9 9)))
>
> (define outer-inner-loop
> (λ (x y x-max y-max)
> (begin
> (printf "~a ~a~n" x y)
> (cond [(and (>= x x-max) (>= y y-max)) 'done]
> [(< y y-max) (outer-inner-loop x (add1 y) x-max y-max)]
> [else (outer-inner-loop (add1 x) 0 x-max y-max)]))))
>
> (test)
>
> Is this the typical way you would implement "outer-inner looping"
> in Scheme?
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme