Kip, Is this what you are looking for:
hcla=: 13 :'x#:y'
]d=:2 2 2 hcla i:2
1 1 0
1 1 1
0 0 0
0 0 1
0 1 0
hcinvla=:hcla^:_1 hcla
hcinvla d
|length error: hcinvla
| hcinvla d
hcla
#:
hcinvJ=:#:^:_1
hcinvJ
#:^:_1
hcinvJ d
6 7 0 1 2
hcinvla
#.
hcinvla=: 13 :'#.y'
hcinvla d
6 7 0 1 2
Raul's new improved answer hc doesn't appear to deal with the negative
values. My inverse does the best it can with the data it gets.
My code is mostly from the dictionary. I'm not sure what would be the best
way to deal with negative binary numbers. Maybe I'll remember something
about that a little later.
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Kip Murray
Sent: Saturday, December 10, 2011 1:02 AM
To: Programming forum
Subject: Re: [Jprogramming] How #: should have been designed
Now we need an inverse for Raul's improved #: ("hash colon")
hc NB. Raul's improved #:
{.@#:@(,: (2 * |))
hc i: 2
1 1 0
1 1 1
0 0 0
0 0 1
0 1 0
hcinv NB. improvement sought
2&#.`(2&#.@}. - 2 ^ <:@#)@.{."1
hcinv hc i: 2
_2 _1 0 1 2
On 12/8/2011 2:41 PM, Raul Miller wrote:
...
But this would work just as well, as a model:
{.@#:@(,: 2 * |)i:2
1 1 0
1 1 1
0 0 0
0 0 1
0 1 0
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm