Skip to content

Instantly share code, notes, and snippets.

(ns fizz_buzz.core)
(defn fizz-buzz-number [num]
(let [is-multiple-of? (fn [n] (= 0 (rem num n)))
a-multiple-of-3 (is-multiple-of? 3)
a-multiple-of-5 (is-multiple-of? 5)
a-multiple-of-both (and a-multiple-of-3
a-multiple-of-5)]
(cond
a-multiple-of-both "FizzBuzz"
(ns fizz_buzz.core)
(defn fizz-buzz [coll]
(let
[fizz-buzz-number
(fn [num]
(let [is-multiple-of? (fn [n] (= 0 (rem num n)))
a-multiple-of-3 (is-multiple-of? 3)
a-multiple-of-5 (is-multiple-of? 5)
a-multiple-of-both (and a-multiple-of-3
user=> (range 1 16)
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
user=> (defn is-multiple-of? [num n]
#_=> (= 0 (rem n num)))
#'user/is-multiple-of?
user=> (def is-multiple-of-3?
#_=> (partial is-multiple-of? 3))
#'user/is-multiple-of-3?
user=> (is-multiple-of-3? 3)
true
(defn fizz-buzz [coll]
(clojure.string/join
\space
(map #(let [s (str %2 %3) ]
(if (seq s)
s
(str %)))
coll
(cycle [ "" "" "Fizz" ])
(cycle [ "" "" "" "" "Buzz" ]))))
describe("A project landings list page", function () {
var TestTools = require('./TestTools'),
Navigation = require('./Navigation'),
ptor;
beforeEach(function () {
TestTools.resetTestData();
ptor = protractor.getInstance();
ptor.get('/ebo/#/projects/excecutive-education');
it("removes a landing", function () {
element.all(by.css('.delete')).first().click();
ptor.driver.switchTo().alert().then( // <- this fixes the problem
function (alert) {
alert.accept();
},
function (error) {
}
);
it("removes a landing", function () {
element.all(by.css('.delete')).first().click();
TestTools.switchToAlertAndAccept(ptor); // <- the fix is now in a helper function
expect(
element.all(
by.repeater('landing in project.landings')).count()
).toBe(5);
});
describe("A project landings list page", function () {
var TestTools = require('./TestTools'),
Navigation = require('./Navigation'),
ptor;
beforeEach(function () {
TestTools.resetTestData();
ptor = protractor.getInstance();
ptor.get('/ebo/#/projects/excecutive-education');
it("shows a new 'autoresponder' mailing", function () {
element(by.css('.dropdown .new_mailings')).click(); // <- this fixes it
element(by.css('#new_ma'))
.click().then(function () {
expect(ptor.getCurrentUrl())
.toMatch(
'/projects/excecutive-education/new-mailing/ma'
);
}
);
it("shows a new 'autoresponder' mailing", function () {
TestTools.clickDropdownOption( // <- helper
'.dropdown .new_mailings', '#new_ma'
).then(function () {
expect(ptor.getCurrentUrl())
.toMatch(
'/projects/excecutive-education/new-mailing/ma'
);
}
);