Association from key-value list

Before associations, I dealt quite a bit with key-value lists. AssociationThread makes an association from a list of keys and a separate list of values, but I couldn’t find any function that does the same with a single list, so I made one.
It’s quite simple, but I figure someone might find it helpful.

KeyValListToAssociation[list_] :=
  AssociationThread @@ Transpose@list;
KeyValListToAssociation::usage = "Makes an association from a list of the form {{key1,value1},{key2,value2},{key3,value3}}";


list2d = {{a, 1}, {b, 2}, {c, 3}, {d, 4}};
KeyValListToAssociation[list2d]
1 Like

Cool.

Small typo, I think you meant:

KeyValListToAssociation[list_] :=
  AssociationThread @@ Transpose@list
1 Like

You’re right; I corrected it.