Odd word problem/TrivialCharacterStreamSupportForJ

From Rosetta Code
Revision as of 11:39, 8 November 2011 by Rdm (talk | contribs) (need to be able to get fresh outstreams also)

J lacks a character stream implementation, so this is a minimal sketch of "get a character" and "put a character" code.

Note that this implementation allows only one input stream and one output stream per locale.

<lang j>begin_instream=: 3 :0 NB.

 instream=: y
   last=: _1

)

 getch=: 3 :0
   last=: last+1
   last{instream
 )


clear_outstream=: 3 :0

 outstream=: 

)

 outch=: 3 :0
   outstream=: outstream, y
 )</lang>