MCPcopy Create free account
hub / github.com/argumentcomputer/ix / group_by

Function group_by

crates/compile/src/compile.rs:2850–2874  ·  view source on GitHub ↗

Group consecutive equal elements in a sorted slice. Assumes the input is already sorted by the same relation used for equality testing.

(
  items: Vec<&T>,
  mut eq: F,
)

Source from the content-addressed store, hash-verified

2848 stt: &CompileState,
2849 caller: &'static str,
2850) -> Result<SOrd, CompileError> {
2851 match (stt.resolve_addr(x), stt.resolve_addr(y)) {
2852 (Some(xa), Some(ya)) => Ok(SOrd::cmp(&xa, &ya)),
2853 (None, _) => Err(CompileError::MissingConstant {
2854 name: x.pretty(),
2855 caller: caller.into(),
2856 }),
2857 (_, None) => Err(CompileError::MissingConstant {
2858 name: y.pretty(),
2859 caller: caller.into(),
2860 }),
2861 }
2862}
2863
2864/// Compare two Lean expressions structurally for canonical ordering.
2865/// Strips `Mdata` wrappers, compares by constructor tag, then recurses
2866/// into subexpressions. Constants are compared by address (or mutual index).
2867pub fn compare_expr(
2868 x: &LeanExpr,
2869 y: &LeanExpr,
2870 mut_ctx: &MutCtx,
2871 x_lvls: &[Name],
2872 y_lvls: &[Name],
2873 stt: &CompileState,
2874) -> Result<SOrd, CompileError> {
2875 match (x.as_data(), y.as_data()) {
2876 (ExprData::Mvar(..), _) | (_, ExprData::Mvar(..)) => {
2877 Err(CompileError::UnsupportedExpr {

Callers 1

sort_constsFunction · 0.85

Calls 2

pushMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected