Here is an example of dyadic ;: it parses CSV

mj =. 256 $ 0           NB. X - Other
mj =. 1 (a.i.a.)}mj     NB. C - Char
mj =. 2 (a.i.',')}mj    NB. D - Delim
mj =. 3 (a.i.'"')}mj    NB. Q - Quote
mj =. 4 (a.i.'''')}mj   NB. S - Single Quote


sj =. _2] \"1 }.".;._2  (0 : 0)
NB.    X    C    D    Q    S
      0 0  1 1  2 1  3 1  4 1        NB. 0 - Other
      0 0  1 0  2 2  1 0  1 0        NB. 1 - Char
      0 0  1 1  1 2  3 1  4 1        NB. 2 - Delim
      0 0  3 0  3 0  5 0  3 0        NB. 3 - Quote
      0 0  4 0  4 0  4 0  6 0        NB. 4 - SQuote
      0 0  0 0  2 2  3 0  0 0        NB. 5 - Second Quote
      0 0  0 0  2 2  0 0  4 0        NB. 6 - Second SQuote
)

parse_csv =. (0;sj;mj)&;:


On Fri, Oct 19, 2012 at 9:20 PM, Henry Rich <henryhr...@nc.rr.com> wrote:

> Somewhere there is a description of how to use dyad ;: to emulate monad ;:
> .  You can modify that as required.
>
> Henry Rich
>
>
> On 10/19/2012 8:57 PM, bob therriault wrote:
>
>> What about using cut? (;.)
>>
>>   k=.'blåbærgrød'
>>     k
>> blåbærgrød
>>     t=: (a:-.~<;._2)@,&' '  NB. removing a: to clean up multiple spaces
>>     t k
>> +-------------+
>> |blåbærgrød|
>> +-------------+
>>     k=.'blåbærgrød blåbærgrød'
>>     t k
>> +-------------+-------------+
>> |blåbærgrød|blåbærgrød|
>> +-------------+-------------+
>>     k=.'blåbærgrød         blåbærgrød'
>>     t k
>> +-------------+-------------+
>> |blåbærgrød|blåbærgrød|
>> +-------------+-------------+
>>
>> On 2012-10-19, at 4:05 PM, Bo Jacoby wrote:
>>
>>      k=.'blåbærgrød'
>>>
>>
>> ------------------------------**------------------------------**
>> ----------
>> For information about J forums see 
>> http://www.jsoftware.com/**forums.htm<http://www.jsoftware.com/forums.htm>
>>
>>  ------------------------------**------------------------------**
> ----------
> For information about J forums see 
> http://www.jsoftware.com/**forums.htm<http://www.jsoftware.com/forums.htm>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to