2
$\begingroup$

I have three lists $a=\{1,4,7\}, ~b=\{2,5,8\}, ~c=\{3,6,9\}$. I define a result as this,

    In[1]:= result = {{12, 10, 9} - {10, 5, 1}, {15, 21, 28} - {14, 17, 
    21}, {30, 22, 17} - {27, 16, 8}}

    Out[1]= {{2, 5, 8}, {1, 4, 7}, {3, 6, 9}}.  

I want the output in terms of a, b and c i.e result $=\{b,a,c\}$.

$\endgroup$
  • $\begingroup$ Your vectors a, b and c are not linearly independent, so any answer where the result is not simply a permutation of {a,b,c} is inherently ambiguous. $\endgroup$ – Sascha Sep 9 '16 at 16:21
3
$\begingroup$

Use a replacement rule:

{{12, 10, 9}  - {10, 5, 1},
 {15, 21, 28} - {14, 17, 21},
 {30, 22, 17} - {27, 16, 8}} /. Thread[{{1, 4, 7}, {2, 5, 8}, {3, 6, 9}} -> {"a", "b", "c"}]

(*{b, a, c}*)
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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