Bitwise AND, OR, XOR, NOT for strings?


(David Garamond) #1

(reposted via c.l.r from another email account; post to mailing list
doesn’t seem to get through)

What do people think of adding String#&, String#|, String#^, and
String#~? I find it useful sometimes in Perl. In Ruby currently I have
to convert each byte to integer first, rather slow (actually slow as
mollasses… :slight_smile:

There are BitSet and BitVector modules (and another one which I forgot
for doing bit operations) but ironically none of them currently
provide an easy way to xor two strings together.

···


dave


(Robert) #2

“David Garamond” davegaramond@icqmail.com schrieb im Newsbeitrag
news:e241b76e.0402240558.5dca01ce@posting.google.com

(reposted via c.l.r from another email account; post to mailing list
doesn’t seem to get through)

What do people think of adding String#&, String#|, String#^, and
String#~? I find it useful sometimes in Perl. In Ruby currently I have
to convert each byte to integer first, rather slow (actually slow as
mollasses… :slight_smile:

There are BitSet and BitVector modules (and another one which I forgot
for doing bit operations) but ironically none of them currently
provide an easy way to xor two strings together.

I once hacked some BitSet together that could be initialized with a String
and converted back to a String. If you’re interested I could mail it to
you. (If I find it back, that is. :-))

robert

(Ara.T.Howard) #3

this is a great idea. it might also be useful to have

String.and! other
String.or! other
String.xor! other
String.not!

which did not create copies.

-a

···

On 24 Feb 2004, David Garamond wrote:

(reposted via c.l.r from another email account; post to mailing list
doesn’t seem to get through)

What do people think of adding String#&, String#|, String#^, and
String#~? I find it useful sometimes in Perl. In Ruby currently I have
to convert each byte to integer first, rather slow (actually slow as
mollasses… :slight_smile:

There are BitSet and BitVector modules (and another one which I forgot
for doing bit operations) but ironically none of them currently
provide an easy way to xor two strings together.

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: http://www.ngdc.noaa.gov/stp/
TRY :: for l in ruby perl;do $l -e “print “\x3a\x2d\x29\x0a””;done
===============================================================================


(David Garamond) #4

Ara.T.Howard wrote:

What do people think of adding String#&, String#|, String#^, and
String#~? I find it useful sometimes in Perl. In Ruby currently I have
to convert each byte to integer first, rather slow (actually slow as
mollasses… :slight_smile:

There are BitSet and BitVector modules (and another one which I forgot
for doing bit operations) but ironically none of them currently
provide an easy way to xor two strings together.

this is a great idea. it might also be useful to have

String.and! other
String.or! other
String.xor! other
String.not!

which did not create copies.

Thanks for the responses. I’m gonna try submitting this as an RCR.

···


dave