diff --git a/changelog.md b/changelog.md index a1a24545..67c68d4b 100644 --- a/changelog.md +++ b/changelog.md @@ -20,7 +20,7 @@ This version is not yet released. If you are reading this on the website, then t - Add the experimental [`fft`](https://uiua.org/docs/fft) function, which performs the Fast Fourier transform - The inverse FFT is also supported via [`un °`](https://uiua.org/docs/un) - Add the experimental [`astar`](https://uiua.org/docs/astar) modifier, which performs the A* pathfinding algorithm -- Add the experimental [`with ⫯`](https://uiua.org/docs/with) modifier, which is a complement to [`on ⟜`](https://uiua.org/docs/on) and [`by ⊸`](https://uiua.org/docs/by) +- Add the experimental [`but ⫯`](https://uiua.org/docs/but) modifier, which is a complement to [`on ⟜`](https://uiua.org/docs/on) and [`by ⊸`](https://uiua.org/docs/by) - Adjacent [`trace ⸮`](https://uiua.org/docs/trace)s now function as a single [`trace ⸮`](https://uiua.org/docs/trace) of more values - N+1 adjacent [`stack ?`](https://uiua.org/docs/stack)s now format to N [`trace ⸮`](https://uiua.org/docs/trace)s - Add the [`&camcap`](https://uiua.org/docs/&camcap) system function, which captures a frame from a camera diff --git a/site/primitives.json b/site/primitives.json index 4f47c591..eadf22c8 100644 --- a/site/primitives.json +++ b/site/primitives.json @@ -414,6 +414,14 @@ "class": "Planet", "description": "Call two functions on two distinct sets of values" }, + "but": { + "glyph": "⫯", + "outputs": 1, + "modifier_args": 1, + "class": "Stack", + "description": "Call a function but keep its last argument on the top of the stack", + "experimental": true + }, "by": { "glyph": "⊸", "outputs": 1, @@ -1248,14 +1256,6 @@ "class": "DyadicArray", "description": "The n-wise windows of an array" }, - "with": { - "glyph": "⫯", - "outputs": 1, - "modifier_args": 1, - "class": "Stack", - "description": "Call a function but keep its last argument on the top of the stack", - "experimental": true - }, "xlsx": { "args": 1, "outputs": 1, diff --git a/src/compile/modifier.rs b/src/compile/modifier.rs index 1181a68d..943967f3 100644 --- a/src/compile/modifier.rs +++ b/src/compile/modifier.rs @@ -447,7 +447,7 @@ impl Compiler { }}; } match prim { - Dip | Gap | On | By | With => { + Dip | Gap | On | By | But => { // Compile operands let (mut instrs, sig) = self.compile_operand_word(modified.operands[0].clone())?; // Dip (|1 …) . diagnostic @@ -488,7 +488,7 @@ impl Compiler { instrs.insert(0, Instr::Prim(Pop, span)); Signature::new(sig.args + 1, sig.outputs) } - prim if prim == On || prim == With && sig.args <= 1 => { + prim if prim == On || prim == But && sig.args <= 1 => { instrs.insert( 0, if sig.args == 0 { @@ -543,7 +543,7 @@ impl Compiler { } Signature::new(sig.args.max(1), sig.outputs + 1) } - With => { + But => { let mut i = 0; if sig.args > 1 { instrs.insert( diff --git a/src/primitive/defs.rs b/src/primitive/defs.rs index bdecd0de..ed91f46d 100644 --- a/src/primitive/defs.rs +++ b/src/primitive/defs.rs @@ -1685,11 +1685,11 @@ primitive!( /// : [⫯+ 2 5] /// : [⫯- 2 5] /// - /// [with] can be used to copy a value from deep in the stack, or to move it. + /// [but] can be used to copy a value from deep in the stack, or to move it. /// ex: # Experimental! /// : [⫯⊙⊙⊙∘ 1 2 3 4] /// : [⫯⊙⊙⊙◌ 1 2 3 4] - ([1], With, Stack, ("with", '⫯')), + ([1], But, Stack, ("but", '⫯')), /// Call a function on two sets of values /// /// For monadic functions, [both] calls its function on each of the top 2 values on the stack. diff --git a/src/primitive/mod.rs b/src/primitive/mod.rs index d4ca18c2..1d4fa70f 100644 --- a/src/primitive/mod.rs +++ b/src/primitive/mod.rs @@ -386,7 +386,7 @@ impl Primitive { use SysOp::*; matches!( self, - With | (Coordinate | Astar | Fft | Triangle | Case) + But | (Coordinate | Astar | Fft | Triangle | Case) | Sys(Ffi | MemCopy | MemFree | TlsListen) | (Stringify | Quote | Sig) ) @@ -834,7 +834,7 @@ impl Primitive { | Primitive::Dip | Primitive::On | Primitive::By - | Primitive::With + | Primitive::But | Primitive::Gap | Primitive::Un | Primitive::Under