learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-41.scm (533B)


      1 (define-library (sicp solutions chapter-2 exercise-41)
      2   (import (scheme base)
      3           (only (sicp solutions chapter-2 exercise-40) unique-pairs)
      4           (only (sicp utils) enumerate-interval flatmap))
      5   (export unique-triples)
      6 
      7   (begin
      8     (define (unique-triples n)
      9       (flatmap (lambda (pair)
     10                  (map (lambda (k)
     11                         (append pair (list k)))
     12                       (enumerate-interval 1 (- (cadr pair)
     13                                                1))))
     14                (unique-pairs n)))))