[Jprogramming] Word splitter
Blake McBride
blake at mcbride.name
Sun Mar 25 11:30:26 HKT 2012
You know what. As I think about it some more, perhaps APL was wrong.
On Sat, Mar 24, 2012 at 10:26 PM, Blake McBride <blake at mcbride.name> wrote:
> There is a bug in yours and mine.
>
> $words''
>
> should be 0 0
>
> On Sat, Mar 24, 2012 at 10:19 PM, Blake McBride <blake at mcbride.name>wrote:
>
>> Mine looks better! (ha)
>>
>>
>> On Sat, Mar 24, 2012 at 10:17 PM, Henry Rich <HenryHRich at nc.rr.com>wrote:
>>
>>> J has come a long way:
>>>
>>> ];._1&(','&,) 'hello there,how,are,you today?'
>>> hello there
>>> how
>>> are
>>> you today?
>>>
>>> Henry Rich
>>>
>>> On 3/24/2012 11:08 PM, Blake McBride wrote:
>>> > Greetings,
>>> >
>>> > Years ago I wrote a function in APL to take a string vector and split
>>> it
>>> > into a matrix at the point of the commas in the string. It really
>>> came in
>>> > handy for the business applications I was writing. I converted it to
>>> J and
>>> > thought I would share it as follows:
>>> >
>>> > words =: 3 : 0
>>> >
>>> (($r),>./r)$(,r>/i.>./r=._1+(r,1+$a)-0,r=.(a=',')#1+i.$a)#inv(a~:',')#a=.,y
>>> > )
>>> >
>>> >
>>> > words 'hello there,how,are,you today?'
>>> > hello there
>>> > how
>>> > are
>>> > you today?
>>> >
>>> >
>>> > Blake McBride
>>> > ----------------------------------------------------------------------
>>> > For information about J forums see http://www.jsoftware.com/forums.htm
>>> >
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>>
>>
>
More information about the Programming
mailing list