It might be that in retrospect, an LSB-approach to #: would have been more
in the spirit of J. It would have allowed us to give the monad #: its
proper rank of zero, for example.
.. that said, it works against the grain of "most important information
first", as expressed in our usual left-to-right positional numeral system.
For example, would we be satisfied with results like these?
10 10 10 #: 123 NB. 3 units, 2 tens, 1 hundred
3 2 1
24 60 60 #: 27001 NB. 1 second, 30 minutes, 7 days
1 30 7
Sometimes, J has to make compromises with established usage (viz, % and e.
).
-Dan
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Raul Miller
Sent: Tuesday, December 13, 2011 10:22 AM
To: Programming forum
Subject: Re: [Jprogramming] How #: should have been designed
After some thought, I am in favor of this version (I think first
proposed by Henry):
((* * <&0) ,. #:) i:3
_1 0 1
_1 1 0
_1 1 1
0 0 0
0 0 1
0 1 0
0 1 1
#. ((* * <&0) ,. #:) i:3
_3 _2 _1 0 1 2 3
Note also:
2 | ((* * >&0) ,. #:) i:3
0 0 1
0 1 0
0 1 1
0 0 0
1 0 1
1 1 0
1 1 1
That said this could be further "improved" by making the #: result
follow the p. result pattern (least significant bit first):
(|.@#: ,. * * <&0) i:3
1 1 _1
1 0 _1
0 1 _1
0 0 0
1 1 0
1 0 0
0 1 0
(|.@#: , * * <&0)"0 i:3
1 0 _1
0 1 _1
1 _1 0
0 0 0
1 0 0
0 1 0
1 1 0
#.@|. :(#. |.)"1 (|.@#: ,. * * <&0) i:3
_1 _3 _2 0 3 1 2
#.@|. :(#. |.)"1 (|.@#: , * * <&0)"0 i:3
_3 _2 _1 0 1 2 3
2 p.~ (|.@#: , * * <&0)"0 i:3
_3 _2 _1 0 1 2 3
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm