[racket] Racket style question
20 minutes ago, Rodolfo Carvalho wrote:
>
> (define (pythagorean-triple/alt n)
> (for*/first ([a (in-range 1 n)]
> [b (in-range a n)]
> [c (in-value (- n a b))]
> #:when (right-triangle? a b c))
> (list a b c)))
You can also use `for*/or':
(define (pythagorean-triple/alt n)
(for*/or ([a (in-range 1 n)]
[b (in-range a n)])
(define c (- n a b))
(and (right-triangle? a b c) (list a b c))))
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!