3 (require "amb-eli.rkt")
5 (define (an-integer-starting-from n)
6 (amb n (an-integer-starting-from (+ n 1))))
8 (define (an-integer-between low high)
10 (amb low (an-integer-between (+ low 1) high)))
14 If we replace an-integer-between with an-integer-starting-from, then
15 the k grows too high to invalid ranges and never stops. The way to accomplish
16 correct values is to restrict i, j and k to valid ranges.
20 ;; using euclid's formula
21 ;; http://en.wikipedia.org/wiki/Pythagorean_triple#Generating_a_triple
22 (define (pythagorean-triples)
23 (let [(n (an-integer-starting-from 1))]
24 (let [(m (an-integer-starting-from n))]
26 (list (- (sqr m) (sqr n))
28 (+ (sqr m) (sqr n))))))