From: Martin Asser Hansen Date: 2011-01-18T18:48:37+09:00 Subject: [ruby-core:34553] Feature request - Low level bitwise operations on char arrays (or class String) --0016e6408b08e7f900049a1bcd99 Content-Type: text/plain; charset=ISO-8859-1 Hello ruby-core, I was wondering why Ruby don't have a low level implementation of bitwise operators for strings. This is extremely useful for detecting changes in strings such as Hamming Distance - which in Perl is super efficient: sub hamming_distance($$) { length( $_[ 0 ] ) - ( ( $_[ 0 ] ^ $_[ 1 ] ) =~ tr[\0][\0] ) } The optimal implementation would perform bitwise operations on machine words at a time (i.e. 32 or 64 bits). This feature is also useful for bitarrays. Cheers, Martin --0016e6408b08e7f900049a1bcd99 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello ruby-core,


I was wondering why Ruby= don't have a low level implementation of bitwise operators for strings= . This is extremely useful for detecting changes in strings such as Hamming= Distance - which in Perl is super efficient:

sub hamming_distance($$)
{=
length( $_[ 0 ] ) - ( ( $_[ 0 ] ^ $_[ 1 ] ) =3D~ tr[\0][\0] )=
}

The optimal implementation would perf= orm bitwise operations on machine words at a time (i.e. 32 or 64 bits).
This feature is also useful for bitarrays.



C= heers,

Martin
--0016e6408b08e7f900049a1bcd99--