a is a list {1,2,3,4}
b is an association <|1->a, 2->b, 3->c, 4->d|>
I am trying to write a single line of code to get b from a
b=<|#->myFunction[#] &|> /@ a
Here is the output:
Association[#1->myFunction[#1]&][1]
Can someone help find out a correct way to do it?
btw, I can do it using for loop, of course, just trying to see if I can use only one line to do it :-)
b = <|# -> myFunction[#]|> & /@ a
do not use()
for function parametersMathematica uses
[]
$\endgroup$a = Range[4]; b = CharacterRange["a", "d"]; Association@((#[[1]] -> #[[2]] &) /@ Transpose[{a, b}])
$\endgroup$