12

Why does this fail L is [1,2,3,4], and this works: L = [1,2,3]?

But L is 1, and L = 1 both work the same.

pferor
  • 179
  • 7
TheOne
  • 9,685
  • 19
  • 74
  • 111

1 Answers1

28

is should only be used when evaluating arithmetic operations on the right-hand side. i.e.:

X is 1 + 2 + 3

is/2 evaluates the right-hand structure as an arithmetic expression. If it is not a valid arithmetic expression or a number, is/2 fails. Otherwise, the number to which the arithmetic expression evaluted is unified with the [presumably] unbound left-hand value.

Nicholas Carey
  • 60,260
  • 12
  • 84
  • 126
TheOne
  • 9,685
  • 19
  • 74
  • 111