[plt-scheme] Why does this code pause at the end

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Fri Mar 5 14:14:49 EST 2010

It is probably the test coverage computation (ie the code that decides
whether or not to color in the source text based on test coverage).
Sometimes that gets slow and I need to look into fixing it (I did some
work on it, so things might be faster now if you're not using the
latest version.)


On Fri, Mar 5, 2010 at 11:40 AM, wooks <wookiz at hotmail.com> wrote:
> Running this in Advanced Student. It's a fast version of Pascals
> Triangle implemented by computing each row before it returns a result.
> The program returns it's result but a (relatively) long pause ensues
> before the scheme prompt appears. Wondering why.
> (define (pascal-row row)
>  (cons 1
>        (local [(define (sum-neighbours row)
>                  (if (or (empty? row)
>                          (empty? (rest row)))
>                      row
>                      (cons (+ (first row) (second row))
>                            (sum-neighbours (rest row)))))]
>          (sum-neighbours row))))
> (define (pascal n k)
>  (cond
>    [(> k n) (pascal k n)]
>    [else (local [(define (pascal m previous-row)
>                    (cond
>                      [(= m n) (+ (list-ref previous-row (sub1 k))
>                                  (list-ref previous-row k))]
>                      [else (pascal (add1 m) (pascal-row previous-
> row))]))]
>            (pascal 0 empty))]))
> (pascal 345 235)
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.