Can anyone provide a reason it would be undesirable to have a scalar left (x)
argument to #: behave any differently than x (#.^:_1) y ?
In NuVoc I find - "
x #: y is used only when you need to state how many places you want in the
result, or if x contains differing values. If you want just sufficient places
to hold the value of y in the base x, use #.inv to convert to a fixed base.
#.inv is the same as #.^:_1 .
"
A scalar extension of x is applied in expression x #. y and scalar extension
of the default 2 in the monodic forms of both #. and #:
So why discriminate against other base values by not extending a scalar left
argument?
I think this would be a useful scalar extension and make sense when explaining
#: and #. to students.
Here are some simple examples around what I'm talking about.
#: 1234 NB. special case within special case??
1 0 0 1 1 0 1 0 0 1 0
#. 1 0 0 1 1 0 1 0 0 1 0
1234
NB. Base 10 is pretty common for most of us.
10 #. 1 2 3 4
1234
10 #: 1234
4
10 (#.^:_1) 1234
1 2 3 4
10 10 10 #: 1234
2 3 4
10 10 10 (#.^:_1) 1234
2 3 4
(,10) (#.^:_1) 1234
4
10 (#.^:_1) 6?.20000
1 6 1 9 4
1 4 3 2 6
0 3 3 4 2
1 1 2 2 0
1 7 5 4 1
1 5 1 0 8
NB. other bases can be fun too e.g.
29r3 (#.^:_1) 6?.20000
1 22r3 26r3 8r3 7r3
1 16r3 8 3 0
0 3 6 20r3 7
1 7r3 4 0 20r3
1 28r3 10r3 19r3 17r3
1 19r3 19r3 17r3 26r3
I can't imagine any broken applications resulting from extending scalar x, but
I'm all ears for hearing about one.
Well, I guess if you really wanted the modulo of a number and used #: instead
of | then you would need to make the left argument be a vector (or just replace
#: by | ) but ... since -
(29r3 #: 6?.20000) -: 29r3 | 6?.20000
1
would anyone suffer from losing that identity?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm