Skip to main content

I can convert an expression with the head of Times,for example, 12*12.5*13*13.5*14*14.5 to {12, 12.5, 13, 13.5, 14, 14.5} by using the code below:

ReleaseHold[HoldForm[1212.51313.514*14.5] /. Times -> List]

ReleaseHold[HoldForm[12*12.5*13*13.5*14*14.5] /. Times -> List] 

I have a list which contains a lot of such expressions,here is an example:

listSample={1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5}

listSample={12*12.5*13*13.5*14*14.5, 12*12.5*13*13.5*14*14.5,12*12.5*13*13.5*14*14.5, 12*12.5*13*13.5*14*14.5,12*12.5*13*13.5*14*14.5,12*12.5*13*13.5*14*14.5} 

I still want to convert all the heads Times to List,but I failed when tried to Map HoldForm to each listItem,because it alway evaluates first. Here is my code:

ReleaseHold[HoldForm[#] /. Times -> List]&/@listSample

ReleaseHold[HoldForm[#] /. Times -> List]&/@listSample 

I want to get this result:

{{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5}}

I can convert an expression with the head of Times,for example, 12*12.5*13*13.5*14*14.5 to {12, 12.5, 13, 13.5, 14, 14.5} by using the code below:

ReleaseHold[HoldForm[1212.51313.514*14.5] /. Times -> List]

I have a list which contains a lot of such expressions,here is an example:

listSample={1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5}

I still want to convert all the heads Times to List,but I failed when tried to Map HoldForm to each listItem,because it alway evaluates first. Here is my code:

ReleaseHold[HoldForm[#] /. Times -> List]&/@listSample

I want to get this result:

{{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5}}

I can convert an expression with the head of Times,for example, 12*12.5*13*13.5*14*14.5 to {12, 12.5, 13, 13.5, 14, 14.5} by using the code below:

ReleaseHold[HoldForm[12*12.5*13*13.5*14*14.5] /. Times -> List] 

I have a list which contains a lot of such expressions,here is an example:

listSample={12*12.5*13*13.5*14*14.5, 12*12.5*13*13.5*14*14.5,12*12.5*13*13.5*14*14.5, 12*12.5*13*13.5*14*14.5,12*12.5*13*13.5*14*14.5,12*12.5*13*13.5*14*14.5} 

I still want to convert all the heads Times to List,but I failed when tried to Map HoldForm to each listItem,because it alway evaluates first. Here is my code:

ReleaseHold[HoldForm[#] /. Times -> List]&/@listSample 

I want to get this result:

{{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5}}

Tweeted twitter.com/#!/StackMma/status/220466165443608576
Source Link
withparadox2
  • 2.5k
  • 1
  • 25
  • 29

Convert head Times to List

I can convert an expression with the head of Times,for example, 12*12.5*13*13.5*14*14.5 to {12, 12.5, 13, 13.5, 14, 14.5} by using the code below:

ReleaseHold[HoldForm[1212.51313.514*14.5] /. Times -> List]

I have a list which contains a lot of such expressions,here is an example:

listSample={1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5, 1212.51313.51414.5}

I still want to convert all the heads Times to List,but I failed when tried to Map HoldForm to each listItem,because it alway evaluates first. Here is my code:

ReleaseHold[HoldForm[#] /. Times -> List]&/@listSample

I want to get this result:

{{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5},{12, 12.5, 13, 13.5, 14, 14.5}}