Ah! ah!

     (,: datatype each) ]`(".each)"0  list
┌───────┬───────┬───────┬────────┬───────┬────────┐
│foo    │1      │bar    │2.17    │baz    │3.14    │
├───────┼───────┼───────┼────────┼───────┼────────┤
│literal│boolean│literal│floating│literal│floating│
└───────┴───────┴───────┴────────┴───────┴────────┘

  That is what I was looking for.

It is useful to process columns of a .csv file read with readcsv (tables/csv) when there is a cycle in the "type" (char/num) of columns:

 'col1 col2 col3 col4'=.|:  ]`(".each) "0  readcsv filename

for a four-column table where the field "type" is char,num,char,num.


  Thanks to Martin and Henry.

Devon's flexible expression is very valuable, but above the basic need here.

P.S. Martin, your paper on Rank in the early times of J (ACM APL91? Proceedings) is where I understood the Rank conjunction. It was new to those who had not used SharpAPL. Is it too late to express thanks for such a good description?

~ Gilles

Le 2023-02-25 à 16:39, Henry Rich a écrit :
Now that gerund"n applies gerund cyclically, the need for the oblique trick is reduced.

Henry Rich

On 2/25/2023 3:26 PM, neit...@gaertner.de wrote:
I want to convert the second one into numerical data
Can you simplify the above expression?
Applying a gerund cyclically, as asked for in the subject:

       ] list =. ;: 'foo 1 bar 2.17 baz 3.14'
+---+-+---+----+---+----+
|foo|1|bar|2.17|baz|3.14|
+---+-+---+----+---+----+

    , ]`(".each)/.  list
+---+-+---+----+---+----+
|foo|1|bar|2.17|baz|3.14|
+---+-+---+----+---+----+

    (,: datatype each)  , ]`(".each)/.  list
+-------+-------+-------+--------+-------+--------+
|foo    |1      |bar    |2.17    |baz    |3.14    |
+-------+-------+-------+--------+-------+--------+
|literal|boolean|literal|floating|literal|floating|
+-------+-------+-------+--------+-------+--------+


Obliquing over a vector is often overlooked.  It picks up every item
as a singleton "diagonal".  The final "," is required to compensate
for that.

                        Martin Neitzel
----------------------------------------------------------------------
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

Reply via email to