Associative Array from variablesCan somebody help me with a correct syntax to create Associative Array from variables?
Now I have this:
a = {"a1", "a2", "a3"};
b = {"b1", "b2", "b3"};
AB = [
"AA" => a,
"BB" => b
];
AB["AA"];It returns:
/*:
a
I want it to return:
/*:
{"a1", "a2", "a3"}I tried different combinations of Eval List(), Eval Expr(), Expr() and Eval(), but no luck.
Thanks!
Advanced Statistical ModelingConsumer and Market ResearchRe: Associative Array from variablesYou almost had it! You need to input the arguments to Associative Array() as Associative Array( keys, values ), instead of Associative Array( {keys, values} ),
a = {"a1", "a2", "a3"};
b = {"b1", "b2", "b3"};
keys = {"AA", "BB"};
values = Eval List({a, b});
AB = Associative Array(keys, values);
AB["AA"];Re: Associative Array from variablesHad to go brute force way for now:
AB = Associative Array();
AB["AA"] = Eval List(a);
AB["BB"] = Eval List(b);
Re: Associative Array from variablesThis does not produce the desired result. Keep in mind, keys are "AA" and "BB", and values for those keys are lists a and b, respectively.
But it got me on the correct track, so this works as intended:
a = {"a1", "a2", "a3"};
b = {"b1", "b2", "b3"};
keys = {"AA", "BB"};
values = Eval List({a, b});
AB = Associative Array({keys, values});
AB["AA"];Thanks!
P.S. Actually it doesn't work either.
I can't understand how JMP decides which one to use if my values are lists too??
//Create an associative array from a list that contains two lists of a key-value pair:
map = Associative Array( {{"yes", 0}, {"no", 1}} );
//Create an associative array from a list of keys and a list of values:
map = Associative Array( {"yes", "no"}, {0, 1} );
Re: Associative Array from variablesAB = Associative Array(EvalList({a, b}))