logoalt Hacker News

danieldk11/07/20240 repliesview on HN

Operators like - are just an infix functor for a Prolog term with arity 2:

    ?- functor(123-"foo", Name, Arity, Type).
    Name = (-),
    Arity = 2,
    Type = compound.

    ?- 1-"foo" = '-'(1,"foo").
    true.
Functors like - only become arithmetic in combination with is:

    ?- A is '-'(42, 1).
    A = 41.
    
    ?- A is 42 - 1.
    A = 41.