[Jprogramming] Binary representation without #: or #.

Aai agroeneveld400 at gmail.com
Wed Dec 28 02:06:06 HKT 2011



    |.@:(2| [:}: <. at -:^: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



More information about the Programming mailing list