You may need to dlimit argument to 1!:2 ,eg 
y 1!:2[2  or y 1!:2 ]2 or y 1!:2(2) or y (1!:2) 2

For what is worth, C, similar to J, does not have any i/o instructions in its
core language. All i/o are supposed to be done by external i/o library.

You can try the ncurses addons for text mode interface.

Чтв, 29 Дек 2011, PackRat писал(а):
> Most well known programming languages have a built-in command to get 
> data entered on the keyboard by the user (e.g., input, etc.) and 
> another built-in command to send/display data to the screen (e.g., 
> print, etc.).  However, these "simple" commands SEEM nonexistent or 
> nearly impossible in J.
> 
> For example, from "Learning J" and the Dictionary, I learned that 
> keyboard input could be accomplished via the foreign conjunction 1!:1 1 
> and that output to the screen could be done via 1!:2 2.  I had thought 
> to write cover verbs along these lines:
> 
> input=: 3 : 0
>   y
>   entry=. 1!:1 1
> )
> 
> display=: 3 : 0
>   y 1!:2 2
> )
> 
> I thought I could then use something similar to these lines of code:
> 
> d=. input 'enter something'
> display d
> 
> However, regarding keyboard input, the Dictionary states that 1!:1 1 
> "read from the keyboard (does not work within a script)".  Well, for 
> pete's sake, what then DOES work within a script?
> 
> Regarding keyboard output, when I use the foreign conjunction above (in 
> the "display" cover verb) to display output, I get the following error:
> 
> |rank error: display
> |   y     1!:2 2
> 
> I get the same error with a direct call to the conjunction:
> 
> |rank error: txttest
> |   'Hello, world!'    1!:2 2
> 
> These are usually the first and easiest commands a beginner learns in 
> virtually every programming language.  Based on the above, J seems not 
> to fit this paradigm.
> 
> This is the first time I've tried to write some somewhat interactive 
> code in J between the user and the program.  How in the world does one 
> implement these absolutely BASIC commands in J?  I'm trying to get 
> simple user input (NOT using complicated forms) to create calls to one 
> of several explicit verbs within a script.  Any help, please, with 
> this?  Many thanks in advance!
> 
> 
> Harvey
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to