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
| (ns powerset.core-test | |
| (:use (clojure set test))) | |
| (defn powerset [s] | |
| (apply union | |
| #{s} ;the complete set of all s | |
| (map (fn [i] (powerset (disj s i))) s))) | |
| (deftest test-powerset | |
| (is (= #{#{}} |
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
| //based on code from http://www.arcfn.com/2009/03/y-combinator-in-arc-and-java.html and the generic version https://gist.github.com/2571928 | |
| class YFact { | |
| // T function returning a T | |
| // T -> T | |
| public static interface Func<T> { | |
| T apply(T n); | |
| } | |
| // Higher-order function returning a T function |
NewerOlder