Something like this, untested

'Valeur' (({.@] i. <@[) { |:@}.@]) data

Сб, 03 мар 2018, raoul schorer написал(а):
> Dear all,
> 
> I am learning J and stumbled on something today:
> 
> I loaded a .csv and obtained a boxed table, that I assigned to the name
> 'data'.
> 
> The first row of 'data' looks like that:
> 
> │N°IPP│Nom du paramètre│Valeur│Valeur Unit│Heure│
> 
> 
> Then I defined two functions, that do work as expected:
> 
> NB. Column index of data y by name x
> 
> colIdxByName =: 4 : 'I. (0 { y) = <x'
> 
> 
> NB. Select a column in data y by index x
> 
> colByIdx =: 4 : '}.x{|:y'
> 
> 
> But if I try:
> 
> colByName =: 4 : 0
> 
> idx =. x colIdxByName y
> 
> res =. idx colByIdx y
> 
> )
> 
> 'Valeur' colByName data  NB. nothing happens...
> 
> idx =: 'Valeur' colIdxByName data
> 
> idx colByIdx data  NB. this doesn't work
> 
> 2 colByIdx data  NB. but this does...
> 
> 
> How can I elegantly compose colIdxByName and colByIdx ?
> 
> 
> Cheers,
> 
> Raoul
> 
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to