mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-24 12:08:28 +00:00
Support those who prefer no left padding
This commit is contained in:
parent
4cc019f038
commit
f87f279198
@ -1023,6 +1023,7 @@ function _composeOp(a, b, func) {
|
|||||||
div: [numeralArgs((a, b) => a / b)],
|
div: [numeralArgs((a, b) => a / b)],
|
||||||
mod: [numeralArgs(_mod)],
|
mod: [numeralArgs(_mod)],
|
||||||
pow: [numeralArgs(Math.pow)],
|
pow: [numeralArgs(Math.pow)],
|
||||||
|
log2: [numeralArgs(Math.log2)],
|
||||||
band: [numeralArgs((a, b) => a & b)],
|
band: [numeralArgs((a, b) => a & b)],
|
||||||
bor: [numeralArgs((a, b) => a | b)],
|
bor: [numeralArgs((a, b) => a | b)],
|
||||||
bxor: [numeralArgs((a, b) => a ^ b)],
|
bxor: [numeralArgs((a, b) => a ^ b)],
|
||||||
|
|||||||
@ -159,6 +159,19 @@ const timeToRands = (t, n) => timeToRandsPrime(timeToIntSeed(t), n);
|
|||||||
*/
|
*/
|
||||||
export const run = (n) => saw.range(0, n).floor().segment(n);
|
export const run = (n) => saw.range(0, n).floor().segment(n);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name binary
|
||||||
|
* Creates a discrete pattern using binary representation.
|
||||||
|
* @param {number} n - input number to convert to binary
|
||||||
|
* @example
|
||||||
|
* "hh".s().struct(binary(5))
|
||||||
|
* // "hh".s().struct("1 0 1")
|
||||||
|
*/
|
||||||
|
export const binary = (n) => {
|
||||||
|
const nBits = reify(n).log2(0).floor().add(1);
|
||||||
|
return binaryN(n, nBits)
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name binaryN
|
* @name binaryN
|
||||||
* Creates a discrete pattern using binary representation.
|
* Creates a discrete pattern using binary representation.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user