0

So basically in GNU-Prolog, I have some code like this:

....
( integer(X) -> write("TRUE"), nl
  ;             write("FALSE"), nl
),
write(X /\ 0xff), nl.

And according to the output, I am sure that X is and integer..

But what I am confused is that, the second output is something like this:

435321 /\ 0xff

and what I am expecting is the value of 435321 /\ 0xff...

What is wrong here? Could anyone give me some help?

false
  • 10,264
  • 13
  • 101
  • 209
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
  • 1
    Please note that write("TRUE"). produces (by default) [84,82,85,69] in GNU. See also: http://stackoverflow.com/questions/8264699/what-is-the-difference-between-and-in-prolog/8269897#8269897 – false Jun 17 '14 at 10:20
  • @false Hi, false, Yes, I know it, I just want to make a simple example..:) – lllllllllllll Jun 17 '14 at 14:02
  • 1
    If you say `write('TRUE')` instead, everything would be fine. – false Jun 17 '14 at 14:31

1 Answers1

2

Prolog evaluates arithmetic expressions only in some specific situations (is, arithmetic comparisons, etc...)

You should do this: Result is X /\ 0xff, write(Result).

Sergii Dymchenko
  • 6,890
  • 1
  • 21
  • 46