This file contains 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
// initial version | |
import scala.collection.immutable.TreeSet | |
class TreeMember[A] { | |
// some really important stuff here, of course! ;~) | |
} | |
class Main { | |
implicit val treeOrder = new Ordering[TreeMember[A]] { | |
def compare(a: TreeMember[A], b: TreeMember[A]) = { | |
// elided for simplicity's sake | |
} |
This file contains 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 prime-factors-test | |
(:use clojure.test midje.sweet)) | |
(defn factors-starting-at [f n] | |
(cond | |
(> f (Math/sqrt n)) (if (= n 1) [] [n]) | |
(= 0 (mod n f)) (cons f (factors-starting-at f (/ n f))) | |
:else (recur (inc f) n))) | |
(defn prime-factors-of [n] |
This file contains 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
// 1: how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |