3

As I found I can use from $ and # in the shortened version of the suspend in Prolog. Hence, I can write the following query:

?- X $> 2, X = 2.5.

And the result is:

X = 2.5
Yes (0.11s cpu)

So what is the difference between # and $ and why the result of the following query:

?- X #> 2, X = 2.5.

is:

No (0.02s cpu)

?

false
  • 10,264
  • 13
  • 101
  • 209
OmG
  • 18,337
  • 10
  • 57
  • 90

1 Answers1

3

Both of them used for the suspension in the prolog in lib(suspend). However, the difference is $ for the real numbers and # is for integers. Hence, the query X #> 2, X = 2.5. was rejected. For example for the query of X #> 2, X = 3. you will get yes and it is the same for the general case X $> 2, X = 3.

OmG
  • 18,337
  • 10
  • 57
  • 90
  • 3
    This is implementation and library specific behaviour. You should tag your question appropriately, mention what libraries are loaded, etc. – User9213 Apr 13 '19 at 03:48
  • @User9213 as mentioned in the question it is in the `lib(suspend)`. BTW, the answer is updated. – OmG Apr 13 '19 at 10:43
  • I don't even know which Prolog this is. GNU-Prolog? SWI? SICSTUS? something else? – User9213 Apr 13 '19 at 12:14
  • Really, SWI-Prolog? Can you link to the documentation? I didn't find it either in the standard library nor in the packages nor in the user-submitted packs :-( I would really like to know where it is hiding. – User9213 Apr 13 '19 at 13:31
  • @User9213 Indeed it's in the ECLiPse libraries http://www.eclipseclp.org/doc/bips/lib/suspend/index.html – OmG Apr 13 '19 at 19:15
  • 2
    The convention of using # to indicate operations on integers and $ to indicate operations on reals is used in several other of ECLiPSe's constraint-related libraries, e.g. the interval solver http://eclipseclp.org/doc/bips/lib/ic and the linear programming solver http://eclipseclp.org/doc/bips/lib/eplex – jschimpf Apr 13 '19 at 22:30