Skip to main content
Became Hot Network Question
clarified question and title
Source Link
Tapiocaweasel
  • 1.6k
  • 3
  • 20

Why does this Association show its Head, and how do I make it evaluate?

Evaluating <|"key" -> {<|"key" -> "val"|>}|> /. {<|stuff__|>} :> <|stuff|>

Produces <|"key" -> Association["key" -> "val"]|>

Why is Association showing its Head there? If I use Rule instead of RuleDelayed its the same. Version 14How do I make the Association[key->val] resolve?

Since I wasn't clear in my original title and question, I'm also looking to a solution to this.2 The mechanism appears to be the same or similar to that described in Evaluated vs. unevaluated Association but, as with my original title to this question was, those discussion are much more focused on explaining the reasoning.

Domen's answer to this question Associations in replacement rules variable seems to me to suggest that using Rule vs RuleDelayed might help, as it does in the answer there, but that is not true for my case.

Why does this Association show its Head

Evaluating <|"key" -> {<|"key" -> "val"|>}|> /. {<|stuff__|>} :> <|stuff|>

Produces <|"key" -> Association["key" -> "val"]|>

Why is Association showing its Head there? If I use Rule instead of RuleDelayed its the same. Version 14.2

Why does this Association show its Head, and how do I make it evaluate?

Evaluating <|"key" -> {<|"key" -> "val"|>}|> /. {<|stuff__|>} :> <|stuff|>

Produces <|"key" -> Association["key" -> "val"]|>

Why is Association showing its Head there? If I use Rule instead of RuleDelayed its the same. How do I make the Association[key->val] resolve?

Since I wasn't clear in my original title and question, I'm also looking to a solution to this. The mechanism appears to be the same or similar to that described in Evaluated vs. unevaluated Association but, as with my original title to this question was, those discussion are much more focused on explaining the reasoning.

Domen's answer to this question Associations in replacement rules variable seems to me to suggest that using Rule vs RuleDelayed might help, as it does in the answer there, but that is not true for my case.

edited tags
Link
Domen
  • 41.5k
  • 3
  • 58
  • 84
Source Link
Tapiocaweasel
  • 1.6k
  • 3
  • 20

Why does this Association show its Head

Evaluating <|"key" -> {<|"key" -> "val"|>}|> /. {<|stuff__|>} :> <|stuff|>

Produces <|"key" -> Association["key" -> "val"]|>

Why is Association showing its Head there? If I use Rule instead of RuleDelayed its the same. Version 14.2