2 (:use [sicp.ch2-2 :only (enumerate-interval accumulate append)]
3 [sicp.ch1-2 :only (prime?)]))
5 ;; Define a procedure unique-pairs that, given an integer n,
6 ;; generates the sequence of pairs (i,j) with 1< j< i< n.
7 ;; Use unique-pairs to simplify the definition of prime-sum-pairs
13 (map (fn [j] (list i j))
14 (enumerate-interval 1 (- i 1))))
15 (enumerate-interval 1 n))))
17 (defn prime-sum? [pair]
18 (prime? (+ (first pair)
19 (first (rest pair)))))
21 (defn make-pair-sum [pair]
22 (list (first pair) (first (rest pair)) (+ (first pair)
23 (first (rest pair)))))
25 (defn prime-sum-pairs [n]
26 (map make-pair-sum (filter prime-sum? (unique-pairs n))))