Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.5K Views
|
6 Replies
|
1 Total Like
View groups...
Share
Share this post:

Create an association using multiple manner of keys to retrieve the values

Posted 3 years ago
POSTED BY: Hongyi Zhao
6 Replies
Posted 3 years ago

But, if you want "uniform access" exactly, maybe you could use Dataset:

Yes. This is exactly what I want to achieve. Thank you again for your wonderful tricks.

Regards, Zhao

POSTED BY: Hongyi Zhao
Posted 3 years ago

I read the goal as "to retrieve the values via both the number index corresponding to their postions and the meaningful keys"

Retrieving a subexpression via index is what Part (the double brackets) does.

But, if you want "uniform access" exactly, maybe you could use Dataset:

BasicVectorsData = Dataset[Take[BasicVectors, 14]];

Now you have:

BasicVectorsData[1] == BasicVectorsData["TricPrim"]
POSTED BY: Eric Rimbey
Posted 3 years ago

Thank you for your comment. This is not a problem, but mainly my personal nitpicking.

Regards, Zhao

POSTED BY: Hongyi Zhao
Posted 3 years ago

Why is that a problem?

POSTED BY: Eric Rimbey
Posted 3 years ago

But one more layer of square brackets must be used.

POSTED BY: Hongyi Zhao
Posted 3 years ago
BasicVectors["TricPrim"] == BasicVectors[[1]]
(*True*)

What this shows is that you can access an Association with Part.

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard