1/ Because the decoration comes before the value, it was easier to put the 0 at the beginning of the display.  That's a weak argument, but that's why I did it that way.

2/ I was just thinking about this last night.  You're right, for consistency complex values should be decorated.  But the point of the decoration is to have a linear form that faithfully reproduces the value.  1j0 does not produce a complex value.  Before the decoration, we need to agree on a way to write a constant that produces a complex precision with imaginary part 0.

3/ I defer to Bill on this.

Henry Rich

On 11/22/2019 1:04 AM, Kirk Iverson wrote:
A recent thread in the programming forum (00 strange?) inspired me to look at 
this new behaviour in 901.

    NB. Numeric
    datatype&.> 'b i f x c'=. 0 1;(0 1+0);(0 1%1);0 1x;0,1j1-0j1
+-------+-------+--------+--------+-------+
|boolean|integer|floating|extended|complex|
+-------+-------+--------+--------+-------+
    b&+
0 1&+
    i&+
00 1&+           <== (1)
    f&+
0 1.&+
    x&+
0 1x&+
    c&+
0 1&+            <== (2)


    NB. Character
    d=. (0{a.);'abc'
    'lctrl lascii'=. d
    'uctrl uascii'=. u:&.> d
    'Uctrl Uascii'=. 10 u:&.> d
    datatype&.>lctrl;lascii;uctrl;uascii;Uctrl;Uascii
+-------+-------+-------+-------+--------+--------+
|literal|literal|unicode|unicode|unicode4|unicode4|
+-------+-------+-------+-------+--------+--------+
    lctrl&,
(00{a.)&,
    lascii&,
'abc'&,
    uctrl&,
(u: 00)&,
    uascii&,
(u: 97 98 99)&,        <== (3)
    Uctrl&,
(10&u: 00)&,
    Uascii&,
(10&u: 97 98 99)&,     <== (3)


1/ Is there a reason that it is the first element of an integer array which has 
extra decoration, rather than the last element (as in the other cases)?

2/ Shouldn't this display as  0 1j0&+   ?
Also, when interpreting constants in a line of J:
0 1    is boolean
00 1   is integer
0 1.   is floating
0 1x   is extended (as is  0 1r1)
0 1j0  is integer
Shouldn't this last one be complex?

3/ Can the representations of uascii and Uascii make use of literals (like 
lascii does)?

/K
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to