SHARE
TWEET

Untitled

a guest Dec 22nd, 2012 20 Never
  1. (map (λ (x) (eqv? x #1))
  2.        (string->list (number->string 12345 2)))
  3.        
  4. (define (permutations size elements)
  5.   (if (zero? size)
  6.       '(())
  7.       (append-map (lambda (p)
  8.                     (map (lambda (e)
  9.                            (cons e p))
  10.                          elements))
  11.                   (permutations (sub1 size) elements))))
  12.        
  13. (permutations 3 '(#t #f))
  14.  
  15. => '((#t #t #t) (#f #t #t) (#t #f #t) (#f #f #t)
  16.      (#t #t #f) (#f #t #f) (#t #f #f) (#f #f #f))
RAW Paste Data
Top