It may be your error or misexpectation. It would help if you posted a reproducible example.
________________________________ From: Ian Shannon <ian.shan...@environment.nsw.gov.au> To: "gene...@jsoftware.com" <gene...@jsoftware.com> Sent: Sunday, December 4, 2016 10:19 PM Subject: [Jgeneral] Possible bug in AMEND Hi there, The following script shows a problem in AMEND using a non-trivial index verb. I have an array typically read in from tab delimited file and boxed up. The first 3 columns contain some text and the rest are numeric. I want to use amend to replace the values each "numeric" column by the actual numeric values using dyad verb ". (numbers). I set up indexes for the required columns and pad to the left with boxed empties to the required dimension. If I use amend with a gerund then the script produces an index error, however it works fine in various other possible configurations. Current J version is 805, but it also occurs in J701. Ian Ian Shannon Science Strategy Branch, Science Division Office of Environment & Heritage P: 02 99 955 490 E: Ian<dot>Shannon <at> Environment <dot> NSW <dot> gov <dot> au W: http <colon> <slash><slash>www <dot> environment <dot> nsw <dot> gov <dot> au location: 33°57'52.1"S 151°05'41.0"E and 33°52'41.2"S 151°12'23.7"E ============================================== NB. AmendProblem.ijs NB. Shows problem with replacing data using "amend" with gerund smoutput JVERSION smoutput '' smoutput 'Script to show amend with gerund error' data =: (<"0 ] 5 3$'asdfghjkzxcvbnm') ,. ": each <"0 ] 10+i. 5 3 data =: ('';'';'';'z') (2 3; 1 4; 0 1 ;_1 _1) } data smoutput 'data array' smoutput data newData =: [ ".&.> (<'99') replaceEmpty numCols@:] { ] replaceEmpty =: $@:] $ [ [`(a: I.@:= ])`]} ,@:] numCols =: [: <@:(a:&;) [: i.&.:(-&3) [: {:@:$ ] NB. generate the indexes into data of the numeric columns NB. this is general in that if 2 ~: #$data it will insert sufficient (<a:) into indexes numCols =: [: < (<a:) replaceEmpty (_1 * #@:$) {. [: < [: i.&.:(-&3) [: {:@:$ ] NB. Box (rank data) (indexes along last dim with numbers) numColsX=: [: < (<a:) , [: < [: i.&.:(-&3) [: {:@:$ ] NB. Box (rank data) (indexes along last dim with numbers) monad define '' indexes =: (numCols data) "_ smoutput ' ',:'calculating indexes before and making into a constant verb in gerund' dataA =: _99 (newData`indexes`] }) data smoutput 'SUCCESS: dataA =: _99 (newData`indexes`] }) data' smoutput ' ',:'calling from directly - no gerund usage' dataB =: (_99 newData data) (numCols data) } data smoutput 'SUCCESS: dataB =: (_99 newData data) (numCols data) } data' smoutput ' ',:'using a simplier index calculation in a gerund' dataC =: _99 (newData`numColsX`] }) data smoutput 'SUCCESS: dataC =: _99 (newData`numColsX`] }) data' try. smoutput ' ',:'using gerund with full index calculation' dataD =. 99 (newData`numCols`] }) data smoutput 'SUCCESS: dataD =: _99 (newData`numCols`] }) data' catch. errNo =. 13!:11 '' errMsg =. 13!:12 '' smoutput 'FAILURE: dataD =: _99 (newData`numCols`] }) data' smoutput 'Error number was ', (": errNo), LF,errMsg end. ) ========================================================= load 'x:/joling/FromProblem.ijs' Engine: j805/j64/windows Beta-12: commercial/2016-09-30T15:50:47 Library: 8.05.02 Qt IDE: 1.4.10/5.4.2 Platform: Win 64 Installer: J805 install InstallPath: r:/j/j64-805 Contact: www.jsoftware.com Script to show amend with gerund error data array ┌─┬─┬─┬──┬──┬──┐ │a│ │d│10│11│12│ ├─┼─┼─┼──┼──┼──┤ │f│g│h│13│ │15│ ├─┼─┼─┼──┼──┼──┤ │j│k│z│ │17│18│ ├─┼─┼─┼──┼──┼──┤ │x│c│v│19│20│21│ ├─┼─┼─┼──┼──┼──┤ │b│n│m│22│23│z │ └─┴─┴─┴──┴──┴──┘ calculating indexes before and making into a constant verb in gerund SUCCESS: dataA =: _99 (newData`indexes`] }) data calling from directly - no gerund usage SUCCESS: dataB =: (_99 newData data) (numCols data) } data using a simplier index calculation in a gerund SUCCESS: dataC =: _99 (newData`numColsX`] }) data using gerund with full index calculation FAILURE: dataD =: _99 (newData`numCols`] }) data Error number was 6 |index error: script | dataD=.99 (newData`numCols`]})data ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- This email is intended for the addressee(s) named and may contain confidential and/or privileged information. If you are not the intended recipient, please notify the sender and then delete it immediately. Any views expressed in this email are those of the individual sender except where the sender expressly and with authority states them to be the views of the NSW Office of Environment and Heritage. PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS EMAIL ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm