Newsgroups: comp.lang.apl
Path: watmath!watserv1!torn.onet.on.ca!utgpu!cs.utexas.edu!sun-barr!ames!elroy.jpl.nasa.gov!jato!csi!sam
From: sam@csi.jpl.nasa.gov (Sam Sirlin)
Subject: Re: Two J Questions
Message-ID: <1992May27.230010.10844@csi.jpl.nasa.gov>
Originator: sam@kalessin
Sender: usenet@csi.jpl.nasa.gov (Network Noise Transfer Service)
Nntp-Posting-Host: kalessin
Organization: Jet Propulsion Laboratory, Pasadena, CA
References:  <1992May27.125334.18688@NCoast.ORG>
Date: Wed, 27 May 1992 23:00:10 GMT
Lines: 46


In article <1992May27.125334.18688@NCoast.ORG>, ppetto@NCoast.ORG (Peter Petto) writes:
|> What is the recommended construct in J that is used for replacing
|> the APL operator that obtains evaluated input from the user.

I'm not sure what "recommended" means, but here's a possibility:
   quad=. ' y. 1!:2 (2) '     NB. write a prompt to the screen
   quad=. quad; '". 1!:1 (1)' NB. read from the screen and execute
   quad=. quad :''

which you might use as
   r=. quad '[]:'

Note that any function (verb) you use in J needs to have at least a
right argument, so you can't come up with a niladic version.

|> I am in the process of translating an example from an article by
|> Robert Brown in an old _Decision Sciences_ to be used in a
|> demonstration for our local PC Users group, which makes extensive use
|> of the quad operator.

Sounds interesting. I've translated some stuff, and I think that the
most trouble will be in the assumptions of default axis (last in apl,
first in J) and in indexing and reassignment.

|> Also, does anyone have a simple function that will send output to the
|> printer?

I haven't done this, but I'd guess you'd write a function that

1. formats the output and writes it in a file
2. uses the host command (0!:0) to setup a dos command to print the
   temp file
3. deletes the temp file

For example:
   print=. 'y. 1!:2 ''temp.dat'''
   print=. print;'0!:0 ''print temp.dat'''
   print=. print, <'0!:0 ''del temp.dat'''
   print=. print : ''

but I haven't tried this.
-- 
Sam Sirlin
Jet Propulsion Laboratory         sam@kalessin.jpl.nasa.gov

