repl build

This commit is contained in:
alex 2022-02-24 12:29:07 +00:00
parent 37a240ee2d
commit 164d007f95
6 changed files with 17 additions and 110803 deletions

View File

@ -53,7 +53,7 @@ Fraction.prototype.min = function(other) {
return this.lt(other) ? this : other;
};
Fraction.prototype.show = function() {
return this.n + "/" + this.d;
return this.s * this.n + "/" + this.d;
};
Fraction.prototype.or = function(other) {
return this.eq(0) ? other : this;
@ -276,6 +276,12 @@ class Pattern {
sub(other) {
return this._opleft(other, (a) => (b) => a - b);
}
mul(other) {
return this._opleft(other, (a) => (b) => a * b);
}
div(other) {
return this._opleft(other, (a) => (b) => a / b);
}
union(other) {
return this._opleft(other, (a) => (b) => Object.assign({}, a, b));
}
@ -316,6 +322,12 @@ class Pattern {
outerJoin() {
return this.outerBind(id);
}
_apply(func) {
return func(this);
}
layer(...funcs) {
return stack(...funcs.map((func) => func(this)));
}
_patternify(func) {
const pat = this;
const patterned = function(...args) {
@ -384,7 +396,7 @@ class Pattern {
return stack(with_pat, without_pat);
}
off(time_pat, func) {
return stack([this, func(this._early(time_pat))]);
return stack(this, func(this.late(time_pat)));
}
every(n, func) {
const pat = this;
@ -447,7 +459,7 @@ class Pattern {
return silence;
}
}
Pattern.prototype.patternified = ["fast", "slow", "early", "late"];
Pattern.prototype.patternified = ["apply", "fast", "slow", "early", "late"];
Pattern.prototype.factories = {pure, stack, slowcat, fastcat, cat, timeCat, sequence, polymeter, pm, polyrhythm, pr};
const silence = new Pattern((_) => []);
function pure(value) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<link rel="icon" href="/tutorial/favicon.e3ab9dd9.ico">
<link rel="stylesheet" type="text/css" href="/tutorial/index.fd7d9b66.css">
<link rel="stylesheet" type="text/css" href="/tutorial/index.a25424f4.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Strudel REPL">
<title>Strudel Tutorial</title>
@ -11,6 +11,6 @@
<body>
<div id="root"></div>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="/tutorial/index.acaced6c.js" defer=""></script>
<script src="/tutorial/index.c743025b.js" defer=""></script>
</body>
</html>