I have an association of the form
ds=<|key1 -> list1, key2 -> list2,... ,keyn -> listn|>
I would like a simple way to map a function to all pairs {a, b}
, where a
is a key and b
is element of the list associated with key a
. I have found several brute-force methods but is seems that there should be something akin to
f /@ ds
This only feeds f
with the lists one by one.
I can do it this way:
g[a_, b_] := h[a, #] & /@ b
Flatten@KeyValueMap[g, ds]
Is there a more compact way?
Value
with the output of the function? Do you replace theKey
? Is the result just supposed to be aList
of the computed values? $\endgroup$