Actually the first item in the list
is used to determine the cuts:
];._1',hello there,how,are,you today?'
hello there
how
are
you today?
];._1'?hello? there,how,are,you? today?'
hello
there,how,are,you
today
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Wednesday, March 28, 2012 2:54 AM
To: 'Programming forum'
Subject: Re: [Jprogramming] Word splitter
>',' cut 'hello there,how,are,you today?'
hello there
how
are
you today?
cut
' '&$: :([: -.&a: <;._2@,~)
This uses cut also:
];._1',','hello there,how,are,you today?'
hello there
how
are
you today?
Oddly, this doesn't work:
;._1',','hello there,how,are,you today?'
|syntax error
| ;._1',','hello there,how,are,you today?'
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Björn Helgason
Sent: Sunday, March 25, 2012 4:04 AM
To: Programming forum
Subject: Re: [Jprogramming] Word splitter
>',' cut 'hello there,how,are,you today?'
2012/3/25 Blake McBride <[email protected]>
> 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
>
--
Björn Helgason, Verkfræðingur
Fornustekkum II
781 Hornafirði,
t-póst: [email protected]
gsm: +3546985532
twitter: @flugfiskur
http://groups.google.com/group/J-Programming
Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
góður kennari getur stigið á tær án þess að glansinn fari af skónum
/|_ .-----------------------------------.
,' .\ / | Með léttri lund verður |
,--' _,' | Dagurinn í dag |
/ / | Enn betri en gærdagurinn |
( -. | `-----------------------------------'
| ) | (\_ _/)
(`-. '--.) (='.'=) ♖♘♗♕♔♙
`. )----' (")_(") ☃☠
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm