This is prettier than mine, but also has problems with negative numbers: |.@:(2| [:}: <.@-:^:a: )&.|: _4 0 0 #: _4 1 0 0
-- Raul On Tue, Dec 27, 2011 at 1:06 PM, Aai <agroeneveld...@gmail.com> wrote: > > > |.@:(2| [:}: <.@-:^:a: )&.|: i.16 > 0 0 0 0 > 0 0 0 1 > 0 0 1 0 > ... > 1 1 0 1 > 1 1 1 0 > 1 1 1 1 > > > > > On 27-12-11 13:13, Kip Murray wrote: >> Can you write a verb br which returns the binary representation of y without >> using #: or #. ? >> >> br 0 >> 0 >> br 2 >> 1 0 >> br i. 5 >> 0 0 0 >> 0 0 1 >> 0 1 0 >> 0 1 1 >> 1 0 0 >> br _13 >> |domain error: br >> | br _13 >> >> An inverse I like is >> >> bv =: (2 p.~ |.)"1 :. br >> >> bv br i. 5 >> 0 1 2 3 4 >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > > -- > Met vriendelijke groet, > @@i = Arie Groeneveld > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm