packages feed

ychr-0.1.0.0: test/golden/compound_term_inspection/compound_term_inspection.chr

:- module(compound_term_inspection, [c2l/1, l2c/1, roundtrip/1, atom0/1, nested/1]).
:- use_module(prelude).
:- chr_constraint c2l/1, l2c/1, roundtrip/1, atom0/1, nested/1.

% compound_to_list: f(1, 2) → [f, 1, 2].
c2l(R) <=> R is compound_to_list(quote(f(1, 2))).

% list_to_compound: [g, a, b] → g(a, b).
l2c(R) <=> R is list_to_compound(quote([g, a, b])).

% Round-trip: c → list → c.
roundtrip(R) <=>
    L is compound_to_list(quote(p(1, foo, bar))),
    R is list_to_compound(L).

% Zero-arg atom: list_to_compound([sym]) → sym (atom).
atom0(R) <=> R is list_to_compound(quote([sym])).

% Nested compound: structure preserved.
nested(R) <=> R is compound_to_list(quote(outer(inner(1, 2), 3))).