Your routine most likely doesn't do what you want it to:

   'abc ' -: 0{:: (<@:])`(<@:".)"1 >'abc';'13.2'
1

The 'abc' got padded when you opened.

You could go for ]`(".&.>)"1. Or {{y 1}~ ".&.> 1{y}}. I don't expect you're likely to find anything much nicer.

(Had j structural under, you might say ".&.(1&{::), but it does not.)

On Tue, 21 Feb 2023, Gilles Kirouac wrote:

I have two character strings :

   datatype each 'abc';'13.2'
┌───────┬───────┐
│literal│literal│
└───────┴───────┘

I want to convert the second one into numerical data

  datatype each (<@:])`(<@:".)"1 >'abc';'13.2'
┌───────┬────────┐
│literal│floating│
└───────┴────────┘

Can you simplify the above expression?


~ Gilles
----------------------------------------------------------------------
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