Professional Web Applications Themes

bitwise AND, OR, XOR, NOT for strings? - Ruby

(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... :-) 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...

  1. #1

    Default bitwise AND, OR, XOR, NOT for strings?

    (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... :-)

    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
    David Guest

  2. #2

    Default Re: bitwise AND, OR, XOR, NOT for strings?


    "David Garamond" <com> schrieb im Newsbeitrag
    news:google.com... 

    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

    Robert Guest

  3. #3

    Default Re: bitwise AND, OR, XOR, NOT for strings?

    On 24 Feb 2004, David Garamond wrote:
     

    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

    --
    ================================================== =============================
    | 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
    ================================================== =============================

    Ara.T.Howard Guest

  4. #4

    Default Re: bitwise AND, OR, XOR, NOT for strings?

    Ara.T.Howard wrote: 
    >
    > 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.[/ref]

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

    --
    dave



    David Guest

Similar Threads

  1. #39443 [NEW]: Bitwise operators (xor)
    By eugene at cleardesign dot com dot ua in forum PHP Bugs
    Replies: 1
    Last Post: November 9th, 09:08 AM
  2. RFD: SHA-1/256/384/512 Bitwise Implementation
    By Mark Shelor in forum PERL Modules
    Replies: 3
    Last Post: October 10th, 03:38 PM
  3. Aggregate Bitwise OR Function
    By Mark in forum IBM DB2
    Replies: 3
    Last Post: September 25th, 06:53 PM
  4. bitwise operator in perl
    By Sam in forum PERL Miscellaneous
    Replies: 1
    Last Post: August 28th, 08:56 AM
  5. bitwise switch statement
    By Kevin Thorpe in forum PHP Development
    Replies: 0
    Last Post: August 4th, 01:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139