The example below shows how J code for one-liners
can be entered on a keyboard more like it is developed -- at
least by me. J parses from right to left and so I find that
my code is written from right to left, but with the existing
user interface the code must be entered left to right. While
there is likely no way to completely alter this situation,
the examples below may help a little.
The example only works in the jconsole mode in
unix/linux for now and I am not sure how to make it work in
an ijx window -- maybe someone can help with that. I don't
even know how to make it work in windows jconsole.
The main idea is captured by the verb rc which
parses tacit verbs pretty well. But one-liner explicit
definitions are more complicated; the long bit of code which
follows is a first crack at parsing one-line explicit verbs.
See the full script far below, please.
"."1;:^:_1"1(([: mt&,[:,&''''[:rc [: }:[: }.])^:(mt&-:@{.))each@:;:;._1 temp
I welcome suggestions.
(B=)
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/
NB. jread.ijs
NB. 2/18/5
NB. 4/10/6 revised
NB. routines to facilitate one-liner definition writing
NB. from left to right ******
rc =: |.&.;:
keyboardIn =: [: 1!:1 3: NB. unix only
NB. usage: rc '[EMAIL PROTECTED]'
NB. usage: read'' (in unix only)
NB. enter as many lines as desired
NB. then type Ctrl-D to break
NB. this system gets confused by parens
NB. so they must be entered backwards (see example below)
mt =: ''''
read =: monad define
temp =: rc keyboardIn y.
"."1;:^:_1"1(([: mt&,[:,&''''[:rc [: }:[: }.])^:(mt&-:@{.))each@:;:;._1 temp
)
test =: noun define
read'' NB. press Ctrl-d to end
%@:/+=:mean
'y. {. 2 / + ~ - 10 * >:' : 13=:rind
}.&2 ; {.&)1+2(=:sparer
NB. press Ctrl-D after the sparer definition above
NB. then you can view the saved definitions by type
NB. the following names
mean
rind
sparer
)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm