7

I have this code:

set_value(X,Value,[X/_|T],[X/Value|T]).
set_value(X,Value,[Y/V|T],[Y/V|NewT):- X\=Y,set_value(X,Value,T,NewT).
set_value(X,Value,[],[X/Value]).

But I cannot figure out what does / do. It looks like it pairs variables, but I'm not 100% sure. It definitely isn't division operator. Thanks.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
peto1234
  • 369
  • 5
  • 11

1 Answers1

10

It doesn't do anything; it's used here to construct pairs, as you already figured.

Since the / doesn't occur on the right-hand side of is or in another place where arithmetic evaluation is performed, Prolog just produces two-argument terms with / as the functor. / is used because it can be written infix; - is also a popular choice for a generic pair constructor.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836