On Sun, 15 Apr 2007, Amelia Stein wrote:

+ Could you just explain what these two lines are actually doing:
+
+ guidance  1!:2 (2)
+ mydata =. 0 : 0
+
+ I see that guidance is defined as just a print statement prompt, but what is
+ the 1!:2(2) business about?

        1!:2 is usually a file write command, but when it's
argument is a 2, as in this case, instead it writes out
directly to the user interface. The left argument of 1!:2 is
what is written, in this case the contents of the noun
'guidance' is written.

        And just as guidance is defined as follows

guidance =: 0 : 0
.
.
.
)

where all the stuff above the final ')' is being defined
as guidance, so would your example of 'mydata =: 0 : 0'


+
+
+ On 4/15/07, Fraser Jackson <[EMAIL PROTECTED]> wrote:
+ >
+ > Amelia,
+ >
+ > I detect a sense of 'panic' about input.  Don't worry, professors too
+ > sometimes have things they really want to work, and have problems working
+ > out exactly what to do.
+ >
+ > The script below goes much further towards solving your problem than it
+ > perhaps should, but you have clearly worked at this, and the discussion on
+ > the forum has raised a number of valuable issues.  I hope the script
+ > clarifies for you why many of us find the task you have been asked to do a
+ > step backwards rather than forwards.  Of course a J session is just a
+ > script
+ > entered line
+ > by line.
+ >
+ > I have attached a script in a quite different style which I think your
+ > hearers might find easier to understand than a script in the graphics for
+ > J
+ > primitives.  You need to modify it for your problem but it does
+ > demonstrate
+ > and easy way of incorporating keyboard input.  Select the text and
+ > copy it to an  .ijs  window and it should run.  Note how it includes
+ > functions, and documentation.   Modify it - perhaps giving a more general
+ > input instruction, and extending the functions output.
+ >
+ > Try
+ >
+ > main ' '
+ >
+ > and follow instructions.
+ >
+ > Fraser
+ >
+ > Script follows
+ > =============================================
+ >
+ >
+ >
+ > load 'primitives'
+ >
+ > guidance =: 0 : 0
+ > Enter a sequence of number pairs
+ > Conclude with a left parenthesis
+ > in the first position in a row
+ > )
+ >
+ > main =: 3 : 0
+ > guidance  1!:2 (2)
+ > mydata =. 0 : 0
+ > NB.  convert mydata to a matrix
+ > moddata =. do open  box  cut _2  mydata
+ > NB.  moddata is now a numeric array with two columns
+ > NB.  and you can do what you want with it
+ > NB.  If you write the commands correctly
+ > NB.  they will produce an array of the output wanted
+ > NB.  with a row for each column
+ > statfns rank 1 transpose moddata
+ > )
+ >
+ > Note 'An example follows'
+ > You might want to emphasize that in J a natural way
+ > to do all this is to have a function main which
+ > defines or loads the functions you want, then to
+ > enter the data and finally to execute it and return
+ > the results of interest.  That way the script is a
+ > complete documentation of the calculations undertaken.
+ > It includes the functions used and the the data or
+ > at least where it was obtained from.  The output is
+ > of course on your session manager window and can
+ > easily be saved, or written to a file if wanted.
+ >
+ > As a statistician who might need to defend the results
+ > having a complete record is extremely valuable.  How
+ > can one recapture the keystrokes entered by a user
+ > unless the output in fact includes them?
+ > )
+ >
+ > maxval =: max insert
+ > minval =: min insert
+ > range  =: maxval - minval
+ > statfns =: maxval,minval,range
+ >
+ >
+ > Note 'Defining your output'
+ > Simple and subtle changes in the function
+ > to generate the statistical values required
+ > can modify how the function organises the
+ > information required.  If your input to the function
+ > main consists of lists of numbers of the same
+ > length it will return an array.
+ >
+ > To obtain the statistics for a list of numbers
+ > statfns =: maxval,minval,range
+ > will provide the definition required.
+ >
+ > To apply it to each column and have the output
+ > of three columns then use
+ >
+ > statfns rank 1 transpose data_matrix
+ >
+ > Alternatively you could define a function
+ > statfns1 =: maxval,minval laminate range
+ > which would place the output with the maxvalues
+ > in the first row, the minvalues in the second and
+ > the range in the final row with columns corresponding
+ > to the original data.
+ >
+ > )
+ >
+ > ----------------------------------------------------------------------
+ > For information about J forums see http://www.jsoftware.com/forums.htm
+ >
+ ----------------------------------------------------------------------
+ For information about J forums see http://www.jsoftware.com/forums.htm
+

(B=) <----------my "sig"

Brian Schott
Atlanta, GA, USA
schott DOT bee are eye eh en AT gee em ae eye el DOT com
http://schott.selfip.net/~brian/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to