Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
describe("Part 1", function() {
it("add calculates that 3 + 4 = 7", function() {
expect(add(3, 4)).toBe(7);
});
it("mdul calculates that 3 * 4 = 12", function() {
expect(mul(3, 4)).toBe(12);
});
it("identityf returns its argument", function() {
var idf3 = identityf(3);
expect(idf3()).toBe(3);
});
it("addf adds two consecutive calls arguments", function() {
expect(addf(3)(4)).toBe(7);
});
it("applyf takes a function and returns it so it can be applied to two consec args", function() {
expect(applyf(add)(3)(4)).toBe(7);
expect(applyf(mul)(5)(6)).toBe(30);
});
it ("curries add with 3", function() {
var add3 = curry(add, 3);
expect(add3(4)).toBe(7);
});
describe("show three ways to implement inc function", function() {
it ("curry 1", function() {
var inc = curry(add, 1);
expect(inc(4)).toBe(5);
expect(inc(inc(4))).toBe(6);
});
it ("addf", function() {
var inc = addf(1);
expect(inc(4)).toBe(5);
expect(inc(inc(4))).toBe(6);
});
it ("applyf", function() {
var inc = applyf(add)(1);
expect(inc(4)).toBe(5);
expect(inc(inc(4))).toBe(6);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.