If I create a data array whose elements are themselves structures, for instance:
let Structure=dataarray(
dataarray("A","B","C"),
initializedictionary("A",1,"B",2),
dataarray("D","E","F")
)
I can use arrayfilter(
to loop through it but not actually process the array elements:
exportdataarray(
arrayfilter(
Structure,
|||
?( seq()<>2,
"data array",
"dictionary"
)
|||
),
¶
)
==>
data array
dictionary
data array
However, if I try to use import()
to access the structure contained in each element, odd things happen. The falsevalue
argument of the if(
function returns the correct value, but when used in the truevalue
argument the import()
function seems to be corrupted if it contains a dictionary or array:
exportdataarray(
arrayfilter(
Structure,
|||
?( seq()=2,
dumpdictionaryquoted(import()),
exportdataarray(import())
)
|||
),
¶
)
==>
A
B
C
D
E
F
and, switching things round to try to achieve the same thing:
exportdataarray(
arrayfilter(
Structure,
|||
?( seq()<>2,
exportdataarray(import()),
dumpdictionaryquoted(import())
)
|||
),
¶
)
==> exportdataarray function: Invalid data array.
That last one will exports the dictionary correctly if it is the falsevalue
, provided the truevalue
hasn’t already caused an error:
exportdataarray(
arrayfilter(
Structure,
|||
?( seq()<>2,
"Array",
dumpdictionaryquoted(import())
)
|||
),
¶
)
==>
Array
A=1
B=2
Array
Note that dumpdictionary(
and dumpdictionaryquoted(
return an empty string in this situation, but exportdataarray(
gives an error.
I frequently use if(
inside arrayfilter(
, usually with text arrays but sometimes data arrays too, but this is the first time I have tried it using a data array of structures. Any idea what is going on?