Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 22nd, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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))