squeezeBind itself + tidying
This commit is contained in:
parent
8ea59067ce
commit
529d448383
2 changed files with 8 additions and 4 deletions
|
|
@ -583,7 +583,7 @@ class Pattern {
|
||||||
return this.innerBind(id);
|
return this.innerBind(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
squeezeJoin() {
|
_squeezeJoin() {
|
||||||
const pat_of_pats = this;
|
const pat_of_pats = this;
|
||||||
function query(state) {
|
function query(state) {
|
||||||
const haps = pat_of_pats.query(state);
|
const haps = pat_of_pats.query(state);
|
||||||
|
|
@ -616,6 +616,10 @@ class Pattern {
|
||||||
return new Pattern(query);
|
return new Pattern(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_squeezeBind(func) {
|
||||||
|
return this.fmap(func).squeezeBind();
|
||||||
|
}
|
||||||
|
|
||||||
_apply(func) {
|
_apply(func) {
|
||||||
return func(this);
|
return func(this);
|
||||||
}
|
}
|
||||||
|
|
@ -678,7 +682,7 @@ class Pattern {
|
||||||
}
|
}
|
||||||
|
|
||||||
_ply(factor) {
|
_ply(factor) {
|
||||||
return this.fmap(x => pure(x)._fast(factor)).squeezeJoin()
|
return this.fmap(x => pure(x)._fast(factor))._squeezeJoin()
|
||||||
}
|
}
|
||||||
|
|
||||||
// cpm = cycles per minute
|
// cpm = cycles per minute
|
||||||
|
|
|
||||||
|
|
@ -491,10 +491,10 @@ describe('Pattern', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe("squeezeJoin", () => {
|
describe("_squeezeJoin", () => {
|
||||||
it("Can squeeze", () => {
|
it("Can squeeze", () => {
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
sequence("a", ["a","a"]).fmap(a => fastcat("b", "c")).squeezeJoin().firstCycle(),
|
sequence("a", ["a","a"]).fmap(a => fastcat("b", "c"))._squeezeJoin().firstCycle(),
|
||||||
sequence(["b", "c"],[["b", "c"],["b", "c"]]).firstCycle()
|
sequence(["b", "c"],[["b", "c"],["b", "c"]]).firstCycle()
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue