[Jprogramming] substr phrase

Henry Rich HenryHRich at nc.rr.com
Thu Jul 27 04:19:48 HKT 2006


These verbs need to be put into a locale of their own so they
don't conflict with names users have already defined.


I propose rank _ 1 rather than 1 1 for this substr.

The substr I use is

substr =: (];.0~ ,.)~"1 _

which takes the substring specifier as x and the string as y.

The J style is for x to be 'control' and y 'data'.  Which is
which in this case is a matter of personal preference, perhaps.

Henry Rich


> -----Original Message-----
> From: programming-bounces at jsoftware.com 
> [mailto:programming-bounces at jsoftware.com] On Behalf Of Oleg Kobchenko
> Sent: Wednesday, July 26, 2006 4:11 PM
> To: Programming forum
> Subject: [Jprogramming] substr phrase
> 
> It's very hard always to figure out the parameters
> to the generic cut conjunction to do simple operations
> like substring.
>  
> I propose to have some common cases specialized
> and add to standard libraries, like "strings", as it is common
> in other language libraries. Or even default library, as for "rplc".
>  
> To start off, here's a verb for substr:
>  
> substr=: (];.0~ ,.)"1
>  
>    '0123456789' substr 3 4
> 3456
> 
>    '0123456789' <@substr 1 2,:3 4
> +--+----+
> |12|3456|
> +--+----+
> 
>    '0123456789' substr 2 4 6,.3
> 234
> 456
> 678
> 
>    ('01234',:'56789') <@substr/ 1 2,:0 4
> +--+----+
> |12|0123|
> +--+----+
> |67|5678|
> +--+----+
> ----------------------------------------------------------------------
> For information about J forums see 
> http://www.jsoftware.com/forums.htm



More information about the Programming mailing list