Raul, the following repairs your tcr size =: [: >./ [: >. (2 ^. |)`(2 ^. >:)@.(0 <: ])"0 extract_bit=: (%&2 @: (-&{.) , ]) 2&| binaryOld=: bit_count extract_bit@]^:["1 ,"0 binary=: size extract_bit@]^:["1 ,"0 tcr=: 2 | binary
tcr }: i: 2 1 0 1 1 0 0 0 1 Kip On 12/30/2011 1:16 AM, Kip Murray wrote: > I figured it out -- you had in mind > > extract_bit=: (%&2 @: (-&{.) , ]) 2&| > > Then > > tcr }: i:2 > 1 1 0 > 1 1 1 > 0 0 0 > 0 0 1 > > The desired result is > > }."1 tcr }: i:2 > 1 0 > 1 1 > 0 0 > 0 1 > > (In general, }: i: 2 ^ <: y is all the integers representable in y bits. > Your verb needs an adjustment for negative arguments.) > > Kip > > On 12/29/2011 7:01 PM, Kip Murray wrote: >> What is at please? >> >> tcr i:4 >> |value error: at >> | tcr i:4 >> >> >> Kip >> >> On 12/28/2011 3:06 PM, Raul Miller wrote: >>> This is a variation on the verb binary defined a >>> http://jsoftware.com/pipermail/programming/2011-December/026213.html >>> >>> effective_magnitude=: (2 * |)^:(-.@-: |) >>> bit_count=: 2<.@^. 1>.>./@,@:effective_magnitude >>> extract_bit=: (%&2 at -&{. , ]) 2&| >>> binary=: bit_count extract_bit@]^:["1 ,"0 >>> >>> tcr=: 2 | binary >>> or >>> >>> tcr=: |@binary >>> >>> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm