Created
January 27, 2011 06:27
-
-
Save deltam/798153 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; c.c.combinatorics/subsetsを使って、べき集合(Powerset)を作る | |
(use '[clojure.contrib.combinatorics :only (subsets)]) | |
(subsets '()) | |
;(()) | |
(subsets '(1)) | |
;(() (1)) | |
(subsets '(1 2)) | |
;(() (1) (2) (1 2)) | |
(subsets '(1 2 3)) | |
;(() (1) (2) (3) (1 2) (1 3) (2 3) (1 2 3)) | |
;; ベクタでもOK | |
(subsets []) | |
;(()) | |
(subsets [2 3]) | |
;(() (2) (3) (2 3)) | |
(subsets [2 3 [2 9]]) | |
;(() (2) (3) ([2 9]) (2 3) (2 [2 9]) (3 [2 9]) (2 3 [2 9])) | |
;; 遅延シーケンスで返している | |
(type (subsets [1 2 3])) | |
;clojure.lang.LazySeq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment