First of all, sorry for the confusing name.
What I want to do is convert {1, 4, 9} to:
{True, False, False, True, False, False, False, False, True}
That is, only the indices from the first list will be True , the rest will be False .
I feel that there is some really simple solution, but I am completely new to both Mathematica and functional programming. I could do it iteratively in a loop, but there must be something that works with the list as a whole. Right?:)
Thanks for your help.
EDIT: to show that I was trying to do something before I asked, here is my progress:
first={1,4,9} ReplacePart[Table[False, {x, Max[first]}], {1} -> True] (* gives {True, False, False, False, False, False, False, False, False} *)
Unfortunately, it does not work with {1,4,9} -> True , but it will work with {1 -> True, 4 -> True, 9 -> True} . But I donβt know how to get to this ...
EDIT 2: received.
ReplacePart[Table[False, {x, Max[first]}], Table[x -> True, {x, first}]]
I will be glad to see your decisions anyway! This one seems like an ugly hack to me ... :)