Pretty code now
This commit is contained in:
parent
2b2646a768
commit
6870b04fb2
1 changed files with 31 additions and 26 deletions
|
|
@ -4133,7 +4133,6 @@ Pattern.prototype.worklet = function (src, ...inputs) {
|
||||||
|
|
||||||
export const worklet = (...args) => pure({}).worklet(...args);
|
export const worklet = (...args) => pure({}).worklet(...args);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a pattern of numbers in base b from a number or pattern of numbers
|
* Creates a pattern of numbers in base b from a number or pattern of numbers
|
||||||
* limited to d digits long from the right
|
* limited to d digits long from the right
|
||||||
|
|
@ -4147,26 +4146,29 @@ export const worklet = (...args) => pure({}).worklet(...args);
|
||||||
* $: note(base("7175 543", 10, 3)).scale("c:major").s("saw")
|
* $: note(base("7175 543", 10, 3)).scale("c:major").s("saw")
|
||||||
* // $: note("1 7 5 5 4 3").scale("c:major").s("saw")
|
* // $: note("1 7 5 5 4 3").scale("c:major").s("saw")
|
||||||
*/
|
*/
|
||||||
export const base = (n, b = 10, d=0) => {
|
export const base = (n, b = 10, d = 0) => {
|
||||||
if(Array.isArray(n)){
|
if (Array.isArray(n)) {
|
||||||
n = sequence(n);
|
n = sequence(n);
|
||||||
}
|
}
|
||||||
n = reify(n);
|
n = reify(n);
|
||||||
b = reify(b);
|
b = reify(b);
|
||||||
d = reify(d);
|
d = reify(d);
|
||||||
|
|
||||||
return d.withValue(e => {
|
return d
|
||||||
return b.withValue(c => {
|
.withValue((e) => {
|
||||||
return n.withValue(v => {
|
return b
|
||||||
|
.withValue((c) => {
|
||||||
|
return n
|
||||||
|
.withValue((v) => {
|
||||||
let digits = [];
|
let digits = [];
|
||||||
let value = v;
|
let value = v;
|
||||||
while (value > 0) {
|
while (value > 0) {
|
||||||
digits.unshift(value % c);
|
digits.unshift(value % c);
|
||||||
value = Math.floor(value / c);
|
value = Math.floor(value / c);
|
||||||
}
|
}
|
||||||
if (e){
|
if (e) {
|
||||||
const l = digits.length;
|
const l = digits.length;
|
||||||
if (l > e){
|
if (l > e) {
|
||||||
digits = digits.slice(-1 * e);
|
digits = digits.slice(-1 * e);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
@ -4179,7 +4181,10 @@ export const base = (n, b = 10, d=0) => {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
return sequence(digits);
|
return sequence(digits);
|
||||||
}).squeezeJoin();
|
})
|
||||||
}).squeezeJoin();
|
.squeezeJoin();
|
||||||
}).squeezeJoin();
|
})
|
||||||
|
.squeezeJoin();
|
||||||
|
})
|
||||||
|
.squeezeJoin();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue