Skip to main content
added 265 characters in body
Source Link
user1066
  • 22.7k
  • 3
  • 36
  • 59
list1 Inner[{#2,#1}&,list2,{0,1}, #2&]

In the example given by the OP (but not in the general case of the question title), all the second elements in list2 are also identical, and Dot may be used to 'multiply a matrix column by a factor', and get the same result:

list1.{{1,0},{0,list2[[1,2]]}}

And:

(list1 Inner[{#2,#1}&,list2,{0,1}, #2&])===(list1.{{1,0},{0,list2[[1,2]]}})

True

Yet another method is the following:

list1 ArrayFlatten[{{1, List/@list2[[All,2]]}}]

For this use of ArrayFlatten see this old SO answer by Janus

Original Answer

 list1 Inner[{1,#1}&,list2,{1,0}, #2&]
list1 Inner[{#2,#1}&,list2,{0,1}, #2&]

In the example given by the OP (but not in the general case of the question title), all the second elements in list2 are also identical, and Dot may be used to 'multiply a matrix column by a factor', and get the same result:

list1.{{1,0},{0,list2[[1,2]]}}

And:

(list1 Inner[{#2,#1}&,list2,{0,1}, #2&])===(list1.{{1,0},{0,list2[[1,2]]}})

True

Original Answer

 list1 Inner[{1,#1}&,list2,{1,0}, #2&]
list1 Inner[{#2,#1}&,list2,{0,1}, #2&]

In the example given by the OP (but not in the general case of the question title), all the second elements in list2 are also identical, and Dot may be used to 'multiply a matrix column by a factor', and get the same result:

list1.{{1,0},{0,list2[[1,2]]}}

And:

(list1 Inner[{#2,#1}&,list2,{0,1}, #2&])===(list1.{{1,0},{0,list2[[1,2]]}})

True

Yet another method is the following:

list1 ArrayFlatten[{{1, List/@list2[[All,2]]}}]

For this use of ArrayFlatten see this old SO answer by Janus

Original Answer

 list1 Inner[{1,#1}&,list2,{1,0}, #2&]
added 425 characters in body
Source Link
user1066
  • 22.7k
  • 3
  • 36
  • 59
list1 Inner[{#2,#1}&,list2,{0,1}, #2&]

In the example given by the OP (but not in the general case of the question title), all the second elements in list2 are also identical, and Dot may be used to 'multiply a matrix column by a factor', and get the same result:

list1.{{1,0},{0,list2[[1,2]]}}

And:

(list1 Inner[{#2,#1}&,list2,{0,1}, #2&])===(list1.{{1,0},{0,list2[[1,2]]}})

True

Original Answer

 list1 Inner[{1,#1}&,list2,{1,0}, #2&]
list1 Inner[{#2,#1}&,list2,{0,1}, #2&]

Original Answer

list1 Inner[{1,#1}&,list2,{1,0}, #2&]
list1 Inner[{#2,#1}&,list2,{0,1}, #2&]

In the example given by the OP (but not in the general case of the question title), all the second elements in list2 are also identical, and Dot may be used to 'multiply a matrix column by a factor', and get the same result:

list1.{{1,0},{0,list2[[1,2]]}}

And:

(list1 Inner[{#2,#1}&,list2,{0,1}, #2&])===(list1.{{1,0},{0,list2[[1,2]]}})

True

Original Answer

 list1 Inner[{1,#1}&,list2,{1,0}, #2&]
added 69 characters in body
Source Link
user1066
  • 22.7k
  • 3
  • 36
  • 59
list1 Inner[{#2,#1}&,list2,{0,1}, #2&]

Original Answer

list1 Inner[{1,#1}&,list2,{1,0}, #2&]
list1 Inner[{1,#1}&,list2,{1,0}, #2&]
list1 Inner[{#2,#1}&,list2,{0,1}, #2&]

Original Answer

list1 Inner[{1,#1}&,list2,{1,0}, #2&]
Source Link
user1066
  • 22.7k
  • 3
  • 36
  • 59
Loading