3

I have a list of this type p = {{y, 1, 3}, {x, 2, 0}, {z, 3, 1/(k + 1)}}

I can use a Do loop that is

    `In: T = {}; Do[AppendTo[T, p[[i]][[1]] -> p[[i]][[2]]  p[[i]][[1]] + p[[i]][[3]]], {i, Length[p]}]
    In: T 
    Out: {y -> 3 + y, x -> 2 x, z -> 1/(1 + k) + 3 z}`

Is there I way I can archive the same output without the Do loop?

wisedoe
  • 239
  • 1
  • 7

1 Answers1

7

The one-liner is

(#1 -> #2 #1 + #3 &) @@@ p

I recommend studying
Where can I find examples of good Mathematica programming practice?
What are the most common pitfalls awaiting new users?
And particularly these answers to the second question:
https://mathematica.stackexchange.com/a/25616/26956
https://mathematica.stackexchange.com/a/18396/26956

LLlAMnYP
  • 11,486
  • 26
  • 65