cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
pmroz
Super User

Insert value to Associative Array

Hello all,

The following code works in JMP 9 but not JMP 8:



Basically I need to put a value into a particular position in an associative array. It appears that in JMP 8, to build an associative array you need to insert values sequentially with INSERT INTO.

I have a workaround but I would really like to use this syntax, which is much more convenient.

Thanks,
Peter
3 REPLIES 3
mattf
Level V

Re: Insert value to Associative Array

Hi:

How about:

pmroz
Super User

Re: Insert value to Associative Array

Hi Matt,

That doesn't work - I want put the string "hello world" into the list pointed to by x["one"], in the first position. What I want to end up with is:

print(x["one"])

{"hello world", "a", "b"}

I have a workaround in place - I was curious if there was a JMP version 8 syntax that I wasn't aware of. The syntax I showed works in version 9 but not 8.

Regards,
Peter
mattf
Level V

Re: Insert value to Associative Array

Yes,

Now I see:
The below works - but coincidenently Insert replaces the first record - does order matter?
<-
x = associative array();
x["one"] = {"", "a", "b"};
x["two"] = {"", "d", "e"};

print(x);

newx = Remove(x, "one");
newx << Insert("Hello World", "a", "b");

print(newx);
-->

produces
x
Associative Array({{"one", {"", "a", "b"}}, {"two", {"", "d", "e"}}})

newx
Associative Array({{"Hello World", "a"}, {"two", {"", "d", "e"}}})


Bset,
-Matt

Recommended Articles