mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-15 23:58:33 +00:00
support catting subpatterns, fixes #87
This commit is contained in:
parent
f4dd549a41
commit
9df20fcbc5
@ -837,7 +837,10 @@ export function stack(...pats) {
|
|||||||
export function slowcat(...pats) {
|
export function slowcat(...pats) {
|
||||||
// Concatenation: combines a list of patterns, switching between them
|
// Concatenation: combines a list of patterns, switching between them
|
||||||
// successively, one per cycle.
|
// successively, one per cycle.
|
||||||
pats = pats.map(reify);
|
|
||||||
|
// Array test here is to avoid infinite recursions..
|
||||||
|
pats = pats.map(pat => Array.isArray(pat) ? sequence(...pat) : reify(pat));
|
||||||
|
|
||||||
const query = function (state) {
|
const query = function (state) {
|
||||||
const span = state.span;
|
const span = state.span;
|
||||||
const pat_n = mod(span.begin.sam(), pats.length);
|
const pat_n = mod(span.begin.sam(), pats.length);
|
||||||
|
|||||||
@ -413,6 +413,12 @@ describe('Pattern', function () {
|
|||||||
['c'],
|
['c'],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it ('Can cat subpatterns', () => {
|
||||||
|
sameFirst(
|
||||||
|
slowcat('a', ['b','c']).fast(4),
|
||||||
|
sequence('a', ['b', 'c']).fast(2)
|
||||||
|
)
|
||||||
|
})
|
||||||
});
|
});
|
||||||
describe('rev()', function () {
|
describe('rev()', function () {
|
||||||
it('Can reverse things', function () {
|
it('Can reverse things', function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user