diff --git a/primitives.md b/primitives.md index 151e4e5..5d3edba 100644 --- a/primitives.md +++ b/primitives.md @@ -43,6 +43,7 @@ | `self` | `'` | Call a function with two copies of the same value | | `flip` | `"` | Call a function with its arguments reversed | | `dip` | `,` | Temporarily pop a value from the stack | +| `gap` | `;` | Pop a value from the stack | | `on` | `o` | Keep the first argument of a function on top of the stack | | `by` | `q` | Keep the last argument of a function below its outputs on the stack | | `both` | `&` | Call the same function on two sets of arguments | diff --git a/src/primitive.rs b/src/primitive.rs index b4ff1f6..61a4cb3 100644 --- a/src/primitive.rs +++ b/src/primitive.rs @@ -74,6 +74,8 @@ prim!(Mod, (Flip, "flip", '"'), /// Temporarily pop a value from the stack (Dip, "dip", ','), + /// Pop a value from the stack + (Gap, "gap", ';'), /// Keep the first argument of a function on top of the stack (On, "on", 'o'), /// Keep the last argument of a function below its outputs on the stack diff --git a/src/runtime.rs b/src/runtime.rs index 0a6a5f9..ed6ec79 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -144,6 +144,10 @@ impl Ufel { self.exec(f.node)?; self.stack.push(a?); } + Mod::Gap => { + let _ = self.pop(1); + self.exec(f.node)?; + } Mod::On => { let a = self.pop(1)?; self.push(a.clone()); diff --git a/src/tree.rs b/src/tree.rs index e7103b3..27be850 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -314,6 +314,7 @@ impl Node { Node::Mod(m, f, _) => match m { Mod::Turn | Mod::Fold => self.handle(f.sig.args, f.sig.outputs), Mod::Dip => self.handle(f.sig.args + 1, f.sig.outputs + 1), + Mod::Gap => self.handle(f.sig.args + 1, f.sig.outputs), Mod::Reduce | Mod::Scan => self.handle(1, 1), Mod::Slf => { self.handle(1, 2);