Feat: lots of things, preparing for live gig
Some checks failed
Deploy Website / deploy (push) Failing after 4m50s

This commit is contained in:
2026-02-15 11:23:11 +01:00
parent 10ca567ac5
commit 670ae0b6b6
59 changed files with 1414 additions and 96 deletions

View File

@@ -838,13 +838,36 @@ impl Forth {
stack.push(Value::Int(if result { 1 } else { 0 }, None));
}
Op::Every => {
Op::Every(word_span) => {
let n = pop_int(stack)?;
let quot = pop(stack)?;
if n <= 0 {
return Err("every count must be > 0".into());
}
let result = ctx.iter as i64 % n == 0;
stack.push(Value::Int(if result { 1 } else { 0 }, None));
record_resolved(&trace_cell, *word_span, ResolvedValue::Bool(result));
if result {
run_quotation(quot, stack, outputs, cmd)?;
}
}
Op::Bjork(word_span) | Op::PBjork(word_span) => {
let n = pop_int(stack)?;
let k = pop_int(stack)?;
let quot = pop(stack)?;
if n <= 0 || k < 0 {
return Err("bjork: n must be > 0, k must be >= 0".into());
}
let counter = match &ops[pc] {
Op::Bjork(_) => ctx.runs,
_ => ctx.iter,
};
let pos = counter % n as usize;
let hit = k >= n || euclidean_hit(k as usize, n as usize, pos);
record_resolved(&trace_cell, *word_span, ResolvedValue::Bool(hit));
if hit {
run_quotation(quot, stack, outputs, cmd)?;
}
}
Op::Quotation(quote_ops, body_span) => {
@@ -1424,6 +1447,13 @@ fn emit_output(
outputs.push(out);
}
fn euclidean_hit(k: usize, n: usize, pos: usize) -> bool {
if k == 0 {
return false;
}
((pos + 1) * k) / n != (pos * k) / n
}
fn euclidean_rhythm(k: usize, n: usize, rotation: usize) -> Vec<i64> {
if k == 0 || n == 0 {
return Vec::new();