0

I have two lists. One with the same repeating four keys and the other with unique values. Both are the same length. I want to Associate the first list with the second list. So if that if the 5th element of the 1st and 2nd list respectively are "noun" and "house, then "house" would be added to the noun key.

wordType = {{"adjective"}, {"verb"}, {"noun"}, {"adverb"}, {"adjective"},{"verb"}}

words= {"pretty", "run", "house", "accordingly", "coarse", "catch"}

AssociationThread[wordType, words]

desired output:

 <|{"adjective"} -> "pretty", {"verb"} -> "run", {"noun"} -> "house", {"adverb"} -> "accordingly",{"adjective"} -> "coarse",{"verb"} -> "catch"|>

actual output:

<|{"adjective"} -> "coarse", {"verb"} -> "catch", {"noun"} ->  "house", {"adverb"} -> "accordingly"|>

you see the "one" key seems to be sloted. It was 1 at the begining but by the end had been replaced with 5. Same with the "two" key.

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
Connor
  • 41
  • 3

1 Answers1

2

Associations cannot have multiple instances (Szabolcs)

Merge[Identity]@Thread@Rule[wordType, words] Works Perfectly! (Edmund)

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Connor
  • 41
  • 3