Group Abstract Group Abstract

Message Boards Message Boards

2
|
4.7K Views
|
1 Reply
|
3 Total Likes
View groups...
Share
Share this post:

AssociationMap: It would be nice to have a key-sequence operator

Posted 10 years ago

I find I am using AssociationMap more and more.

It would be nice to have an equivalent to Map's /@ key-sequence.

For example, suppose <@ could be the sequence for AssociationMap, then we would have:

Sin[Pi/#]&<@Range[10]  

would give:

<|1 -> 0, 2 -> 1, 3 -> Sqrt[3]/2, 4 -> 1/Sqrt[2]|>

Although, perhaps this creates unreadable code for distribution.

POSTED BY: W. Craig Carter

Some functions recently were upgraded to an operator form. That is mentioned in the ref page - see 3rd line:

?AssociationMap

enter image description here

This basically means:

AssociationMap[f]@{a, b, c, d}

enter image description here

So in your case

AssociationMap[Sin[Pi/#] &]@Range[4]

enter image description here

Not exactly what you need, - I just noting perhaps useful thing.

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