[kepler-dev] Converting 'nils' to Strings

Dan Higgins higgins at nceas.ucsb.edu
Thu Feb 9 09:58:04 PST 2006

Hi Christopher,
    I don't know if you guys discussed this or not, but in looking at 
the RExpression actor I noted that I use the the Token 'toString()' 
method. Thus, if 'at' is an arrayToken containing the 3 integers 1,2,3, 
then at.toString() is used to create the string "{1,2,3}".
    So the question is, if one of the tokens in an array is 'nil', then 
what is the result of the 'toString()' method?
    The R system just returns the string 'NA'. If Ptolemy returned 'NA' 
or maybe 'nil' that would make it easy to convert the RExpression actor. 
In any case, it seems to me that it would be useful to have Kepler/PT 
return some string value for 'toString' when a token has the nil 
property rather than throw an exception.

    On a slightly different topic, we talked about an actor that would 
take an array with nils and produce a smaller array without nils. A 
somewhat more general approach used in R that might be very useful is 
the idea of of a 'logical array'. We can certainly have an array of 
boolean values, but R uses a logical array to select parts of another 
array of the same dimensions. In other words, one could use an actor 
that has two array inputs, one a logical array and the other any other 
kind of array with the same dimension. The resulting output is a smaller 
array where only those values corresponding to true values in the 
logical array are retained. Thus, one would remove nils by creating a 
logical array from some arrays where nil values are 'false' and then 
combining that logical array with the original.


Dan Higgins                                  higgins at nceas.ucsb.edu
http://www.nceas.ucsb.edu/    Ph: 805-893-5127
National Center for Ecological Analysis and Synthesis (NCEAS) Marine Science Building - Room 3405
Santa Barbara, CA 93195

More information about the Kepler-dev mailing list