Skip to main content

Module termops

Module termops 

Source
Expand description

Term-introspection builtins: functor/3, arg/3, =../2 (univ), copy_term/2.

Ported byte-for-byte from patch-prolog v1 (solver.rs Functor/Arg/ Univ/CopyTerm arms). Tag decisions verified against the oracle:

  • functor(T, '.', 2) and T =.. ['.', a, b] both build a STR (functor “.”, arity 2), NOT a list cell — v1 always constructs Term::Compound.
  • decomposing a TAG_LST yields functor . / arity 2 and args [Head, Tail] (univ produces ['.', H, T]).
  • errors mirror v1’s structured balls (see the captured oracle strings in the unit tests).

Functions§

plg_rt_b_arg_3
arg/3: the N-th argument of a compound. 1 = success, 0 = fail/error.
plg_rt_b_copy_term_2
copy_term/2: a fresh copy of orig with consistent renamed vars.
plg_rt_b_functor_3
functor/3: decompose or construct. 1 = success, 0 = failure/error.
plg_rt_b_univ_2
=../2 (univ): decompose into / build from a list. 1 = success.