3 ms·
Just to pop in on kebab case: Prolog has a weird third thing going on. Arithmetic only happens in specific contexts. i.e. A is 4 - 2, % arithmetic, technica
by Avshalom 4y ago
Just to pop in on kebab case:
Prolog has a weird third thing going on. Arithmetic only happens in specific contexts. i.e.
A is 4 - 2, % arithmetic, technically is(A,-(4,2)), A is 2
A #= 4 - 2, % arithmetic, A is 2
A = 4-2, % non arithmetic, A is unified with the term -(4,2) which pretty prints as 4-2
A = -2, % non arithmetic but A is the number -2 not a term -(2).
A = 4-2, B is 4 + A, % a weird one A is the term -(4,2) but when it gets called in the context is(B,+(4,A)) it gets treated as the arithmetic '-' and B is 6
you can also kebab-case predicate names so
l-h-t(L,H,T) :- L = [H|T].
?- l-h-t([1,2,3,4],H,T). %works as desired
H = 1,
T = [2, 3, 4].
you can't do it with variables though.