Re: connected?

dvanhorn <[email protected]>
Newsgroups gmane.org.ballistichelmet.lambda
Message-ID <[email protected]>
dvanhorn wrote:
>        [(diagonal-down? x y)
>         (let ((f (if (< x-row y-row) add1 sub1)))
>           (any (lambda (x) (in? x pieces))
>                ((gen-positions
>                  (lambda (x) (= x y-row)) f
>                  (lambda (x) (= x y-col)) f)
>                 (f x-row) (f x-col))))]
> 
>        [(diagonal-up? x y)
>         (let ((f (if (< x-row y-row) add1 sub1))
>               (g (if (< x-row y-row) sub1 add1)))
>           (any (lambda (x) (in? x pieces))
>                ((gen-positions
>                  (lambda (x) (= x y-row)) f
>                  (lambda (x) (= x y-col)) g)
>                 (f x-row) (g x-col))))]

This can be simplified to:

       [else
        (let ((f (if (< x-row y-row) add1 (if (diagonal-up? x y) sub1 add1)))
              (g (if (< x-row y-row) (if (diagonal-up? x y) sub1 add1) add1)))
          (any (lambda (x) (in? x pieces))
               ((gen-diagonal
                 (lambda (x) (= x y-row)) f
                 (lambda (x) (= x y-col)) g)
                (f x-row) (g x-col))))]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.