Code Comments
Programming Forum and web based access to our favorite programming groups.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.
Post Follow-up to this messageNameless 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
Post Follow-up to this message"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.
Post Follow-up to this messageNameless 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
Post Follow-up to this message> "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?
Post Follow-up to this message"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.
Post Follow-up to this message"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]
Post Follow-up to this messageIn 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
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.