It depends on what you really want to accomplish.

For one thing, consider whether you would want to use cut:

   '-' cut 'an-as-tig-mat-ic'
┌──┬──┬───┬───┬──┐
│an│as│tig│mat│ic│
└──┴──┴───┴───┴──┘

That said, if you really want the result you specified, maybe try

fra=: >@(}.&.>~ #{.&-1:)@(<;.2@,&'-')

Or, more explicitly:

fra=:3 :0
  boxed=. <;.2 y,'-'
  > ((-#boxed) {. _1) }.&.> boxed
)

Good luck,

-- 
Raul




On Thu, Mar 23, 2017 at 5:47 AM, Gian Medri <[email protected]> wrote:
> Hi!
>
> I have a=:'an-as-tig-mat-ic' or b=:'tim-ing'
>
> and a function:
>
> fra=: 3 : 0
> p=.(]<;._1 ) '-',y     NB. cut
> o=.<:$p
> p=.>p,each '-'
> ((' ' ([: I. '-' = ])} ]) o{p) o}p  NB. replacing
> )
> fra a
> an-
> as-
> tig-
> mat-
> ic
>    fra b
> tim-
> ing
>
>
> I would like to know if there is a simpler way to get the same result.
>
> Thanks
>
> Gian Medri
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to