>Most agile languages offer a split() function which can split a string
>on any delimiter, with a series of whitespace as the default
Instead of ;: use the function cut from the script 'strings':
load'strings'
'/' cut 'fret/not'
+----+---+
|fret|not|
+----+---+
But if you're looking to parse CSV and upload to databases, don't reinvent the
wheel. Check out the other scripts in the standard library, in particular:
http://www.jsoftware.com/help/user/script_csv.htm
http://www.jsoftware.com/help/user/script_dd.htm
Get a list here:
http://www.jsoftware.com/help/user/libraries.htm
You might also want to check out the new Grid class which allows you to display
and interact with tabular data, and Oleg's CSV editor which uses it. If,
instead of simple CSV files, you have complicated Excel workbooks, check out
Bill Lam's Tara addon:
http://www.jsoftware.com/jwiki/Addons/tables/tara
>Is it possible to specify what the verb ;: will use to split the string?
More than that, the dyad ;: allows you to implement an arbitrary
(non-backtracking) finite state machine (FSM). The monad (see postscript) ;:
implements just such a FSM to parse strings into J tokens. This is different
from splitting on space. For example:
;: '1+2 NB.No spaces around + but many after NB.'
+-+-+-+----------------------------------------+
|1|+|2|NB.No spaces around + but many after NB.|
+-+-+-+----------------------------------------+
><definition url="http://www.jsoftware.com/help/dictionary/d322.htm">
>,:y adds a leading unit axis to y , giving a result of shape 1,$y .
></definition>
You looked up the wrong definition. That's the definition of "laminate", and
is spelled comma-colon ,: as opposed to "word formation" which is spelled
semicolon-colon ;: and is defined here:
http://www.jsoftware.com/help/dictionary/d332.htm
FYI, you can get to the definition of any primitive by typing the primitive,
putting your caret over it, and and pressing CTRL+F1.
-Dan
PS: You'll see the word "monad" a lot when reading documentation and the
Forums. Be advised that we do not mean it in the Haskell sense (I'm not even
sure what that sense is).
In J a monad is simply a verb (function) which takes only one argument (on the
right), as in "reciprocal":
%10
0.1
and is contrasted with a dyad, which is a verb which takes two arguments (one
on the left, one on the right), as in "divide":
2%10
0.2
Often, the monad and dyad definitions of a verb are related, as in the example
above.
(You may be familiar with the terms "unary (or prefix) operator" and "binary
(or infix) operator" from other languages, which are synonymous with monad and
dyad respectively.)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm