I am not sure what was the intention of this
excercise, but it brought about a very nice
mnemonic way to use bitwise ops:
bw=: 1 : '(16+u/@|:&.#:i.4) b.'
+.bw
23 b.
*.bw
17 b.
>bw
18 b.
4 +.bw 2
6
6 *.bw 2
2
6 >bw 2
4
2 +.bw 1 2 8
3 2 10
--- Raul Miller <[EMAIL PROTECTED]> wrote:
> Here's a general bitwise operator for J:
>
> bitwise=:1 :0
> assert. y-:<.y
> #.u #:y
> :
> assert. x-:<.x
> assert. y-:<.y
> X=.#:x
> Y=.#:y
> W=.-X >.&{:&$ Y
> R=.>:`_:@.(_1&=)"0 u b. 0
> #. (X{.~W,~$x) u"R Y{.~W,~$y
> )
>
> For example:
> 2 +.bitwise 1 2 8
> 3 2 10
>
> I am not very confident that my approach for rank for the dyadic
> case is always appropriate, but I can't think of any good
> cases where that matters.
>
> And, unfortunately, I'm not sure this is a candidate for inclusion
> in J (because the logical symbol -- b. -- already has a conflicting
> meaning).
>
> Anyways... perhaps this adverb is of interest to someone?
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm