Skip to content

Commit 216609a

Browse files
committed
remove astar
1 parent 48b938f commit 216609a

File tree

7 files changed

+13
-32
lines changed

7 files changed

+13
-32
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ This version is not yet released. If you are reading this on the website, then t
3535
- This allows filling from the left instead of the right
3636
- Add experimental [`bytes`](https://uiua.org/docs/bytes) function for encoding and decoding byte arrays
3737
- Remove previously deprecated `around ’`
38+
- Remove previously deprecated `astar`
3839
### Interpreter
3940
- Improve pretty-printed array layout
4041
- High-rank arrays take up less vertical space and more horizontal space

site/primitives.json

-7
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,6 @@
371371
"class": "Misc",
372372
"description": "Throw an error if a condition is not met"
373373
},
374-
"astar": {
375-
"outputs": 2,
376-
"modifier_args": 3,
377-
"class": "Algorithm",
378-
"description": "Find shortest paths in a graph",
379-
"deprecated": true
380-
},
381374
"atangent": {
382375
"glyph": "",
383376
"args": 2,

src/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl VirtualEnv {
208208
self.handle_args_outputs(1, parts.len().saturating_sub(1))
209209
}
210210
Node::Unpack { count, .. } => self.handle_args_outputs(1, *count),
211-
Node::Mod(Astar, args, _) | Node::ImplMod(AstarFirst, args, _) => {
211+
Node::ImplMod(Astar, args, _) | Node::ImplMod(AstarFirst, args, _) => {
212212
self.pop();
213213
let [neighbors, heuristic, is_goal] = get_args(args)?;
214214
let has_costs = neighbors.outputs() == 2;

src/compile/modifier.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -279,24 +279,14 @@ impl Compiler {
279279
let span = self.add_span(modifier.span.clone());
280280
Ok(Node::CustomInverse(cust.into(), span))
281281
}
282-
Modifier::Primitive(Primitive::Astar) if pack.branches.len() == 2 => {
283-
self.handle_primitive_deprecation(Primitive::Astar, &modifier.span);
284-
self.handle_primitive_experimental(Primitive::Astar, &modifier.span);
285-
let mut args = EcoVec::with_capacity(3);
286-
for branch in pack.lexical_order().cloned() {
287-
args.push(self.word_sig(branch.map(Word::Func))?);
288-
}
289-
let span = self.add_span(modifier.span.clone());
290-
Ok(Node::Mod(Primitive::Path, args, span))
291-
}
292282
Modifier::Primitive(Primitive::Path) if pack.branches.len() == 3 => {
293283
let mut args = EcoVec::with_capacity(3);
294284
for branch in pack.lexical_order().cloned() {
295285
args.push(self.word_sig(branch.map(Word::Func))?);
296286
}
297287
args.make_mut().swap(1, 2);
298288
let span = self.add_span(modifier.span.clone());
299-
Ok(Node::Mod(Primitive::Astar, args, span))
289+
Ok(Node::ImplMod(ImplPrimitive::Astar, args, span))
300290
}
301291
m if m.args() >= 2 => {
302292
let new = Modified {

src/compile/optimize.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,15 @@ opt!(
293293
ImplMod(PathPop, args.clone(), *span)
294294
),
295295
(
296-
[Mod(Astar, args, span), Prim(First, _)],
296+
[ImplMod(Astar, args, span), Prim(First, _)],
297297
ImplMod(AstarFirst, args.clone(), *span)
298298
),
299299
(
300-
[Mod(Astar, args, span), Push(n), Prim(Take, _)],
300+
[ImplMod(Astar, args, span), Push(n), Prim(Take, _)],
301301
[Push(n.clone()), ImplMod(AstarTake, args.clone(), *span)]
302302
),
303303
(
304-
[Mod(Astar, args, span), Prim(Pop, _)],
304+
[ImplMod(Astar, args, span), Prim(Pop, _)],
305305
ImplMod(AstarPop, args.clone(), *span)
306306
),
307307
);
@@ -328,7 +328,7 @@ impl Optimization for PathOpt {
328328
let node = Mod(Fill, eco_vec![get_fill.clone(), inner], *fill_span);
329329
Some((2, node))
330330
}
331-
[Mod(Astar, args, span), Mod(Fill, fill_args, fill_span), ..] => {
331+
[ImplMod(Astar, args, span), Mod(Fill, fill_args, fill_span), ..] => {
332332
let [get_fill, filled] = fill_args.as_slice() else {
333333
return None;
334334
};

src/primitive/defs.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -2939,10 +2939,6 @@ primitive!(
29392939
/// : ▽⟜≡▽0.5
29402940
/// : ⌵⍜°⍉≡fft .
29412941
(1, Fft, Algorithm, "fft", { experimental: true }),
2942-
/// Find shortest paths in a graph
2943-
///
2944-
/// [astar] is deprecated. Use [path] instead.
2945-
((2)[3], Astar, Algorithm, "astar"),
29462942
/// Find the shortest path between two things
29472943
///
29482944
/// Expects 2 functions and at least 1 value.
@@ -3546,6 +3542,7 @@ impl_primitive!(
35463542
(1, ReplaceRand, Impure),
35473543
(2, ReplaceRand2, Impure),
35483544
(1, CountUnique),
3545+
((2)[3], Astar),
35493546
((2)[3], AstarFirst),
35503547
((1)[3], AstarPop),
35513548
((1)[3], AstarTake),

src/primitive/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ impl fmt::Display for ImplPrimitive {
313313
MatchPattern => write!(f, "pattern match"),
314314
MatchLe => write!(f, "match ≤"),
315315
MatchGe => write!(f, "match ≥"),
316+
Astar => write!(f, "{Path}"),
316317
AstarFirst => write!(f, "{First}{Astar}"),
317318
AstarTake => write!(f, "{Take}…{Astar}"),
318319
AstarPop => write!(f, "{Pop}{Astar}"),
@@ -554,7 +555,6 @@ impl Primitive {
554555
),
555556
Trace => format!("use subscripted {} instead", Stack.format()),
556557
Windows => format!("use {} {} instead", Stencil.format(), Identity.format()),
557-
Astar => format!("use {} instead", Path.format()),
558558
Over => format!("use {With} or {Below} instead"),
559559
_ => return None,
560560
})
@@ -1185,10 +1185,6 @@ impl Primitive {
11851185
})?;
11861186
}
11871187
Primitive::Dump => dump(ops, env, false)?,
1188-
Primitive::Astar => {
1189-
let [neighbors, heuristic, is_goal] = get_ops(ops, env)?;
1190-
path::path(neighbors, is_goal, Some(heuristic), env)?;
1191-
}
11921188
Primitive::Path => {
11931189
let [neighbors, is_goal] = get_ops(ops, env)?;
11941190
path::path(neighbors, is_goal, None, env)?;
@@ -1883,6 +1879,10 @@ impl ImplPrimitive {
18831879
env.insert_stack(outputs, kept)?;
18841880
env.push_all(temp);
18851881
}
1882+
ImplPrimitive::Astar => {
1883+
let [neighbors, heuristic, is_goal] = get_ops(ops, env)?;
1884+
path::path(neighbors, is_goal, Some(heuristic), env)?;
1885+
}
18861886
ImplPrimitive::UndoPartition1 => groups::undo_partition_part1(ops, env)?,
18871887
ImplPrimitive::UndoGroup1 => groups::undo_group_part1(ops, env)?,
18881888
ImplPrimitive::ReduceContent => reduce::reduce_content(ops, env)?,

0 commit comments

Comments
 (0)