Comments on the J distribution j602/2008-03-03/16:45:
1. In 8!:x the p<> modifier is supposed to apply to all
nonnegative values.
But sometimes it isn't applied to a lone 1. This happens
in both the Mac and
the Windows versions. For example:
('p< >m< ->' & (8!:2)) &.> 12.3;_7 3 _4.5; 1 ; 0 ; 1 ;
0 ; 1p1
+-----+--------------+-+--+-+--+------------+
| 12.3| -7.0 3.0 -4.5|1| 0|1| 0| 3.141592654|
+-----+--------------+-+--+-+--+------------+
2. The writecsv verb in j603/system/packages/files/csv.ijs
puts quotes around
every data item, even numbers, when only character data
should be quoted. The
following code, which could probably be improved, seems to
quote the data
properly:
addext =: ] , [ #~ [: -. '.' e. ] }.~ ([: # ]) |
PATHSEP_j_ i:~ ]
fmtchr =: [: < '"' , '"' ,~ > #~ [: >: '"' = >
fmtnum =: 8!:0 & >
isnum =: ([: +:/ 2 131072 e. 3!:0&>)"0
NB.
----------------------------------------------------------------------------
NB. fmtcsv - Convert data to CSV format
NB.
----------------------------------------------------------------------------
fmtcsv =: 3 : 0
try.
;(<toHOST LF) _1}"(1) 1j1 #!.(<',')"1
fmtchr`[email protected] y
catch.
_1
end.
)
NB.
----------------------------------------------------------------------------
NB. writecsv - Store data in a CSV file
NB.
NB. x = Data to be stored
NB. y = File pathname (we append '.csv' if no extension is
given)
NB.
----------------------------------------------------------------------------
writecsv =: 4 : 0
if. _1 -: x =. fmtcsv x do.
_1
else.
x 1!:2 < '.csv' addext y
end.
)
3. It would be very helpful if the online documentation
described the inverse
of a verb (v^:_1) in the section devoted to that verb,
especially for verbs
such as # for which the inverse adds significant new
capabilities. For
example, I have edited my d400.htm file so that the
section on dyadic # says:
If the arguments have an equal number of items, then
x#y copies +/x items
from y, with i{x repetitions of item i{y . Otherwise,
if one is an atom it
is repeated to make the item count of the arguments
equal.
The complex left argument a j. b copies a items
followed by b fills. The fit
conjunction provides specified fills, as in #!.f .
The inverse of Copy is Expand: b #^:_1 y . The left
argument is a boolean
vector with ones indicating where to insert
corresponding items from the
right argument and zeroes indicating where to insert
fills. There must be as
many ones in x as there are items in y or a length
error will result. The
fill item may be specified with the fit conjunction.
For example:
0 0 0 1 0 1 1 0 1 0 #^:_1 ] 1 3 5 7
0 0 0 1 0 3 5 0 7 0
0 0 1 0 0 1 0 0 1 0 0 #^:_1!.'.' 'abc'
..a..b..c..
4. The online manual J for C Programmers contains a few
errors:
declarations.htm:
Dyad $ ($hape) and monad $ ($hape Of): the result has
the shape 5 (x
(i. e. 5) should be the result has the shape 5
loopless_code_j_verbs_have_r.htm:
Negative Verb Rank: The sentence is equivalent to +/ "0
i. 2 3 should be
The sentence is equivalent to +/ "0 i. 3
Rank Makes Verbs Automatically Extensible: or two
vectors should be
or four vectors
Nested Loops: The first few examples don't show the
value of nested ranks:
100 200 300 +"0"0 _ (1 2 3 4) is
equivalent to
100 200 300 +"0 _ (1 2 3 4)
100 200 +"0"_ 0 (1 2 3) is equivalent to
100 200 +"_ 0 (1 2 3)
loopless_code_iv_irregular_o.htm:
A Few J Tricks: if for example x is 2 1 5 the result is
5y2+y+1: should be
if for example x is 2 1 5 the result is 5y2+y+2:
input_and_output.htm:
Format an Array: 8!:n: m=(2{s if n is omitted,
should be
m=(3{s if n is omitted,
Format binary data: 3!:n: This is an integer whose
value is 0x31424344 should be
This is an integer whose value is 0x31424334
applied_mathematics_in_j.htm:
Polynomials: p. : list starts at 2 rather than 1
5. It would be useful to have the following extensions to
the grid class:
Cell Types:
102: Pushbutton, similar to the Ok button often found
on dialogs. For
example, for some applications it is useful to
have a button on each
row. I currently have a GUI where I use the
grid row headers as
delete buttons for each row, but they don't have
the "push in"
animation of a normal button when they are
clicked.
400-499: Set: any combination of the items in (type - 400)
{ CELLITEMS . Each
item has the value x: 2^((type - 400) {
CELLITEMS) i. item, and the
value of the cell is the sum of the values of
the selected items, as
an extended integer (to allow more than 32 items
in a set). For
example, suppose that a cell has type 475, and
75 { CELLITEMS is the
list
----------------------------------------------------
| Monday | Tuesday | Wednesday | Thursday |
Friday |
----------------------------------------------------
We then have the item values Monday = 1x,
Tuesday = 2x, Wednesday =
4x, Thursday = 8x, and Friday = 16x. If Monday,
Wednesday, and
Friday are selected, the cell has the value 21x
(1x + 4x + 16x). If
none of the items is selected, the cell has the
value 0.
Options:
GRIDROWMODE = 2 to highlight entire rows and allow
multiple rows to be
selected. Clicking on any cell in a row
removes any existing
marking and marks that entire row. Subsequent
shift-clicking on a
row highlights the rows from the previously
selected row to the
shift-clicked row, inclusive. Multiple
noncontiguous rows can be
selected by ctrl-clicking on them. This
would be useful for row
operations, for example selecting a range of
rows to be deleted
from the table.
--- Brian
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm