I need to produce this
{{identifier1 === # || identifier1 === _ &, True &}, {identifier2 === # || identifier2 === _ &, True &}, {_ === # || _ === _ &, True &}}
It's basically a list of pairs of {condition, value}. Both condition and value are syntactically both pure functions to allow more flexibility so I can have a master function that can do a lot of things.
The first member of each pair is SameQ-ing the input to an identifier or the Blank (Blanks, as it allows me to have short hands for certain levels). The second member is trivially returning True.
The identifiers come from a list that can vary in content and length and may even contain _.
So to generate this, I have:
In: {#, True &} & /@ (func[#, x] || func[#, _] & /@ {identifier1, identifier2, _})
- this is split into 2 Mapping, so I can illustrate something later
To produce this:
{{func[identifier1, x] || func[identifier1, _], True &}, {func[identifier2, x] || func[identifier2, _], True &}, {func[_, x] || func[_, _], True &}}
Which I will substitute func with SameQ later on.
Of course, I need to add "&" after every:
func[identifier1, x] || func[identifier1, _]
So if I were to insert that:
In: {# &, True &} & /@ (func[#, x] || func[#, _] & /@ {identifier1, identifier2, _})
- this is why I split this into 2 Mapping
I end up with this:
{{# &, True &}, {# &, True &}, {# &, True &}}
Which is wrong.
Is there a way to "escape" the "&", so "#" expands first, then "&" gets applied. Using Evaluate[#] &
and Activate[#] &
does not work.