1
$\begingroup$

I want to make list of subscripted symbols in functional way. So that given edges list I can get something like the list below/

edges = {1 \[DirectedEdge] 3, 1 \[DirectedEdge] 5, 2 \[DirectedEdge] 1, 
     2 \[DirectedEdge] 6, 5 \[DirectedEdge] 2, 5 \[DirectedEdge] 6, 
     6 \[DirectedEdge] 1, 6 \[DirectedEdge] 4}
{Subscript[x, 1 \[DirectedEdge] 3], Subscript[x, 
 1 \[DirectedEdge] 5], Subscript[x, 2 \[DirectedEdge] 1], Subscript[x,
  2 \[DirectedEdge] 6], Subscript[x, 
 5 \[DirectedEdge] 2], Subscript[x, 5 \[DirectedEdge] 6], Subscript[x,
  6 \[DirectedEdge] 1], Subscript[x, 6 \[DirectedEdge] 4]}
$\endgroup$

1 Answer 1

4
$\begingroup$

Found solution by myself.

Subscript[x, #] & /@ edges

My mistake was that I tried

Subscript[x, #&]  /@ edges
$\endgroup$
2
  • 3
    $\begingroup$ Nice job figuring that out. $\endgroup$
    – Rabbit
    Commented Feb 20, 2018 at 0:46
  • 1
    $\begingroup$ Indeed, good job. And welcome on Mathematica.StackExchange! Just a hint: Try to avoid Subscript (except only for display). Internally, it works differently than you would expect and leads to lots of undesired behavior. Just search for Subscript on this site and you will find a plethoria of these issues. See also here or here $\endgroup$ Commented Feb 20, 2018 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.