Create a workspace so that chai will be visible by node REPL.
~/workspace/test/node-chai$ npm install chai
~/workspace/test/node-chai$ node
Import Chai:
(defn naive-fibonacci [n] | |
(condp = n | |
0 1 | |
1 1 | |
(+ (naive-fibonacci (- n 1)) | |
(naive-fibonacci (- n 2))))) | |
(defn fibonacci-draft | |
([n] | |
(fibonacci-draft n 0 1)) |
(ns fourclojure.problem) | |
(comment Maximum Value 38) | |
(defn max-of [& positive-numbers] | |
(let [max-acc | |
(fn [ns acc] | |
(if (empty? ns) | |
acc | |
(recur (rest ns) (if (> (first ns) acc) (first ns) acc))))] |
import org.junit.Test; | |
public class ArrayCovarianceTest { | |
@Test(expected = ArrayStoreException.class) | |
public void cat_should_not_be_set_in_dog_list() { | |
Animal[] animals = new Dog[1]; // array covariance | |
// Java compiler allows the assignment because Dog extends Animal | |
// But the Java runtime throws a "java.lang.ArrayStoreException: Cat" |
(ns clojure-brave-true-exercises.crashcourse-test | |
(:require [clojure.test :refer :all])) | |
(deftest map-empty | |
(testing "empty" | |
(is (= #{} (mapset inc []))))) | |
(defn mapset [f list] #{}) | |
(deftest map-singleton |
; CIDER 0.8.1 (package: 20141120.1746) (Java 1.8.0_111, Clojure 1.8.0, nREPL 0.2.12) | |
clojure-brave-true-exercises.core> (str nil) | |
"" | |
clojure-brave-true-exercises.core> (str) | |
"" | |
clojure-brave-true-exercises.core> (str "hello") | |
"hello" | |
clojure-brave-true-exercises.core> (str "A" "B") | |
"AB" | |
clojure-brave-true-exercises.core> (str :x :y) |
package com.mathieupauly.selectionsort; | |
import org.junit.Test; | |
import static org.assertj.core.api.Assertions.assertThat; | |
public class SelectionSortTest { | |
private SelectionSort selectionSort = new SelectionSort(); |