How can one extract a list of keys and a list of values from the association?
e.g. as = <|a->1, b->2, c->3, d->4|>
lst1 = {a, b, c, d}
lst2 = {1, 2, 3, 4}
Thanks!
How can one extract a list of keys and a list of values from the association?
e.g. as = <|a->1, b->2, c->3, d->4|>
lst1 = {a, b, c, d}
lst2 = {1, 2, 3, 4}
Thanks!
lst1 = Keys @ as
lst2 = Values @ as
{a, b, c, d} {1, 2, 3, 4}
Or
{lst1, lst2} = Transpose @ KeyValueMap[List, as];
lst1
lst2
{a, b, c, d} {1, 2, 3, 4}
Normal, then any of the methods given there may be used. Or you can just useKeysandValuesdirectly. – Mr.Wizard Apr 30 '15 at 19:12