Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Bit-manipulation in ISO Prolog
ISO Prolog has five bit-manipulation predicates:
 
<< (bitwise left shift),
/\ (bitwise and),
\/ (bitwise or), and
\ (bitwise compliment).

So far so good, but how would one perform (rationally and
effectively)

1) bitwise xor, and
2) bitwise not

within the ISO Prolog framework?

TIA.

--
Mail sent to this email address is automatically deleted
(unread) on the server. Send replies to the newsgroup.



Report this thread to moderator Post Follow-up to this message
Old Post
Nameless
08-16-04 08:58 PM


Re: Bit-manipulation in ISO Prolog
Nameless wrote:
> ISO Prolog has five bit-manipulation predicates:
> 
>    << (bitwise left shift),
>    /\ (bitwise and),
>    \/ (bitwise or), and
>    \ (bitwise compliment).
>
> So far so good, but how would one perform (rationally and
> effectively)
>
> 1) bitwise xor, and
> 2) bitwise not
>
> within the ISO Prolog framework?


Could you first give this newsgroup the definitions of "rationally" and
"effectively" that you have in mind, so that this newsgroups does not
try in vain to satisfy your question ?
I am just trying to save on guessing what you mean.

Cheers

Bart Demoen

Report this thread to moderator Post Follow-up to this message
Old Post
Bart Demoen
08-17-04 01:57 AM


Re: Bit-manipulation in ISO Prolog
"Bart Demoen" <bmd@cs.kuleuven.ac.be> wrote in message
news:1092689141.597465@seven.kulnet.kuleuven.ac.be...
> Nameless wrote: 
>
>
> Could you first give this newsgroup the definitions of
> "rationally" and "effectively" that you have in mind, so that
> this newsgroups does not try in vain to satisfy your question ?
> I am just trying to save on guessing what you mean.

No, you're just trying to be difficult (as usual). If you
don't understand English, then don't reply--it's as simple
as that. In fact, I'd really prefer that _you_ didn't reply
to any of my messages; I'm sure there are equally capable
but much nicer people who are able and willing to assist.
Of course, they may well qualify their reply with a
reservation that it may not be as rational and effective as
I had hoped--but beggers can't be choosers. ;)

--
Mail sent to this email address is automatically deleted
(unread) on the server. Send replies to the newsgroup.



Report this thread to moderator Post Follow-up to this message
Old Post
Nameless
08-17-04 08:56 AM


Re: Bit-manipulation in ISO Prolog
Nameless wrote:

> No, you're just trying to be difficult (as usual).

If you ask a solution for a problem without the explicit mentioning
that it needs properties rational and effective, people in this
newsgroup (especially me) are inclined to deliver answers with
those properties. By explicitly mentioning them as requirements,
you make it sound like a trick question, that's why I asked.

But let's focus on the questions and not on their epitheton ornans.

You ask how to do bitewise not ... how is bitwise not different
from what \ does in ISO ? An example would be welcome.

xor(X,Y,Result) :- Result is (X /\ \Y) \/ ((\X) /\ Y).

Is that ok for you ?

> In fact, I'd really prefer that _you_ didn't reply
> to any of my messages

Once you put your message in a newsgroup, it is no longer
yours. Especially if you are nameless.

Cheers

Bart Demoen


Report this thread to moderator Post Follow-up to this message
Old Post
Bart Demoen
08-17-04 01:56 PM


Re: Bit-manipulation in ISO Prolog
> "Nameless" <news.mail@chello.no> wrote in message
> ...


I assume you know this answer for "xor":

xor(X,Y,Z) :- Z is ( (\ X) /\ Y ) \/ ( (\ Y) /\ X ).

(hope no typo mistakes).

and pray that you compiler/interpreter of prolog has a good optimizer.

(note: in general I look always for compilers with and easy interface
to C, in order to be able to add small low level functions).

I agree it is not a great answer, but it is all I have.

PS: Do you known any good reason to do not post with a real name?

Report this thread to moderator Post Follow-up to this message
Old Post
Pere Montolio
08-17-04 01:56 PM


Re: Bit-manipulation in ISO Prolog
"Pere Montolio" wrote in message
news:d0867bad.0408170058.5e355986@posting.google.com... 
>
> I assume you know this answer for "xor":
>
> xor(X,Y,Z) :- Z is ( (\ X) /\ Y ) \/ ( (\ Y) /\ X ).
>
> (hope no typo mistakes).
>
> and pray that you compiler/interpreter of prolog has a good
> optimizer.

Right!

> (note: in general I look always for compilers with and easy
> interface to C, in order to be able to add small low level
> functions).

Pere, I think that's rather missing the point, namely the
absence of (the very useful) 'xor' in ISO Prolog.

From a practical point of view, since most Prologs are
actually implemented in C or a similar imperative language
that has bit-meddling functions, it would be most
surprising not to find matching Prolog predicates. Which is
all the more reason to wonder why ISO Prolog lacks 'xor'.

> I agree it is not a great answer, but it is all I have.

I came up with the same solution too, but this seemed so
clumsy I thought that there must be a better one. I guess
not. Many thanks for confirming this, Pere. I'll be
generous and thank Bart, too. ;)

> PS: Do you known any good reason to do not post with a real
> name?

Yes. ;)

--
Mail sent to this email address is automatically deleted
(unread) on the server. Send replies to the newsgroup.



Report this thread to moderator Post Follow-up to this message
Old Post
Nameless
08-17-04 08:57 PM


Re: Bit-manipulation in ISO Prolog
"Nameless" <news.mail@chello.no> writes:
> Which is all the more reason to wonder why ISO Prolog lacks 'xor'.

I suspect that the committee just couldn't come up with a symbolic operator
they liked :-)
--
mailto:jjk@acm.org                 phone:+49-7031-464-7698 (TELNET 778-7698)
http://www.bawue.de/~jjk/          fax:+49-7031-464-7351
As the air to a bird, or the sea to a fish,
so is contempt to the contemptible. [Blake]

Report this thread to moderator Post Follow-up to this message
Old Post
Jens Kilian
08-17-04 08:57 PM


Re: Bit-manipulation in ISO Prolog
In message <d0867bad.0408170058.5e355986@posting.google.com>, Pere
Montolio <tmp123@menta.net> writes 
>
>
>I assume you know this answer for "xor":
>
>xor(X,Y,Z) :- Z is ( (\ X) /\ Y ) \/ ( (\ Y) /\ X ).

Isn't
xor(X,Y,Z) :- Z is ( X \/ Y ) /\ ( \ (X /\ Y) ).
faster?  It saves one \.

Nick
--
Nick Wedd    nick@maproom.co.uk

Report this thread to moderator Post Follow-up to this message
Old Post
Nick Wedd
09-06-04 09:02 PM


Re: Bit-manipulation in ISO Prolog
Probably, it is.

Report this thread to moderator Post Follow-up to this message
Old Post
Pere Montolio
09-07-04 09:10 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Prolog archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:45 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.