Merge pull request #1226 from heerman/binary

Add binary and binaryN
This commit is contained in:
Felix Roos 2025-01-17 19:27:00 +01:00 committed by GitHub
commit f61916fffa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 109 additions and 2 deletions

View file

@ -46,6 +46,7 @@ import {
rev,
time,
run,
binaryN,
pick,
stackLeft,
stackRight,
@ -959,6 +960,18 @@ describe('Pattern', () => {
expect(run(4).firstCycle()).toStrictEqual(sequence(0, 1, 2, 3).firstCycle());
});
});
describe('binaryN', () => {
it('Can make a binary pattern from a decimal', () => {
expect(binaryN(55532).firstCycle()).toStrictEqual(
sequence(1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0).firstCycle(),
);
});
it('Can make a binary pattern from patterned inputs', () => {
expect(binaryN(pure(0x1337), pure(14)).firstCycle()).toStrictEqual(
sequence(0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1).firstCycle(),
);
});
});
describe('ribbon', () => {
it('Can ribbon', () => {
expect(cat(0, 1, 2, 3, 4, 5, 6, 7).ribbon(2, 4).fast(4).firstCycle()).toStrictEqual(