Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions primitives.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 2 additions & 0 deletions src/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down