Partitioning sublists based on positions, with new partitions immediately following original sublist
$begingroup$
I need to restructure this list nums
:
nums = {{0.0140242, 0.138626, 0.0585034, 0.0509646, 0.0629815, 0.0750587,
0.00588226, 0.272169, 1.},
{0.153123, 0.212751, 0.217497, 0.12154, 0.210508, 0.189625, 0.0680384,
0.0768402, 0.172107},
{0.20766, 0.246923, 0.0924592, 0.142682, 0.110408, 0.20464, 0.246233,
0.251928, 0.07382}};
based on the following rules:
- Every 2nd element in each sublist should be moved/appended to a new vector immediately following its original vector
- Every 3rd element in each sublist should be moved/appended to a new vector immediately following its original vector and the 2nd elements vector
The resulting list should look like:
{{0.0140242, 0.0509646, 0.00588226},
{0.138626, 0.0629815, 0.272169}, // new 2nd elements vector
{0.0585034, 0.0750587, 1.}, // new 3rd elements vector
{0.153123, 0.12154, 0.0680384},
{0.212751, 0.210508, 0.0768402}, // new 2nd elements vector
{0.217497, 0.189625, 0.172107}, // new 3rd elements vector
{0.20766, 0.142682, 0.246233},
{0.246923, 0.110408, 0.251928}, // new 2nd elements vector
{0.0924592, 0.20464, 0.07382}} // new 3rd elements vector
list-manipulation partitions
$endgroup$
add a comment |
$begingroup$
I need to restructure this list nums
:
nums = {{0.0140242, 0.138626, 0.0585034, 0.0509646, 0.0629815, 0.0750587,
0.00588226, 0.272169, 1.},
{0.153123, 0.212751, 0.217497, 0.12154, 0.210508, 0.189625, 0.0680384,
0.0768402, 0.172107},
{0.20766, 0.246923, 0.0924592, 0.142682, 0.110408, 0.20464, 0.246233,
0.251928, 0.07382}};
based on the following rules:
- Every 2nd element in each sublist should be moved/appended to a new vector immediately following its original vector
- Every 3rd element in each sublist should be moved/appended to a new vector immediately following its original vector and the 2nd elements vector
The resulting list should look like:
{{0.0140242, 0.0509646, 0.00588226},
{0.138626, 0.0629815, 0.272169}, // new 2nd elements vector
{0.0585034, 0.0750587, 1.}, // new 3rd elements vector
{0.153123, 0.12154, 0.0680384},
{0.212751, 0.210508, 0.0768402}, // new 2nd elements vector
{0.217497, 0.189625, 0.172107}, // new 3rd elements vector
{0.20766, 0.142682, 0.246233},
{0.246923, 0.110408, 0.251928}, // new 2nd elements vector
{0.0924592, 0.20464, 0.07382}} // new 3rd elements vector
list-manipulation partitions
$endgroup$
add a comment |
$begingroup$
I need to restructure this list nums
:
nums = {{0.0140242, 0.138626, 0.0585034, 0.0509646, 0.0629815, 0.0750587,
0.00588226, 0.272169, 1.},
{0.153123, 0.212751, 0.217497, 0.12154, 0.210508, 0.189625, 0.0680384,
0.0768402, 0.172107},
{0.20766, 0.246923, 0.0924592, 0.142682, 0.110408, 0.20464, 0.246233,
0.251928, 0.07382}};
based on the following rules:
- Every 2nd element in each sublist should be moved/appended to a new vector immediately following its original vector
- Every 3rd element in each sublist should be moved/appended to a new vector immediately following its original vector and the 2nd elements vector
The resulting list should look like:
{{0.0140242, 0.0509646, 0.00588226},
{0.138626, 0.0629815, 0.272169}, // new 2nd elements vector
{0.0585034, 0.0750587, 1.}, // new 3rd elements vector
{0.153123, 0.12154, 0.0680384},
{0.212751, 0.210508, 0.0768402}, // new 2nd elements vector
{0.217497, 0.189625, 0.172107}, // new 3rd elements vector
{0.20766, 0.142682, 0.246233},
{0.246923, 0.110408, 0.251928}, // new 2nd elements vector
{0.0924592, 0.20464, 0.07382}} // new 3rd elements vector
list-manipulation partitions
$endgroup$
I need to restructure this list nums
:
nums = {{0.0140242, 0.138626, 0.0585034, 0.0509646, 0.0629815, 0.0750587,
0.00588226, 0.272169, 1.},
{0.153123, 0.212751, 0.217497, 0.12154, 0.210508, 0.189625, 0.0680384,
0.0768402, 0.172107},
{0.20766, 0.246923, 0.0924592, 0.142682, 0.110408, 0.20464, 0.246233,
0.251928, 0.07382}};
based on the following rules:
- Every 2nd element in each sublist should be moved/appended to a new vector immediately following its original vector
- Every 3rd element in each sublist should be moved/appended to a new vector immediately following its original vector and the 2nd elements vector
The resulting list should look like:
{{0.0140242, 0.0509646, 0.00588226},
{0.138626, 0.0629815, 0.272169}, // new 2nd elements vector
{0.0585034, 0.0750587, 1.}, // new 3rd elements vector
{0.153123, 0.12154, 0.0680384},
{0.212751, 0.210508, 0.0768402}, // new 2nd elements vector
{0.217497, 0.189625, 0.172107}, // new 3rd elements vector
{0.20766, 0.142682, 0.246233},
{0.246923, 0.110408, 0.251928}, // new 2nd elements vector
{0.0924592, 0.20464, 0.07382}} // new 3rd elements vector
list-manipulation partitions
list-manipulation partitions
edited Nov 25 '18 at 23:45
kglr
189k10206424
189k10206424
asked Nov 25 '18 at 23:12
briennakhbriennakh
4899
4899
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Join @@ Transpose[nums[[All, # ;; ;; 3]] & /@ {1, 2, 3}]
{{0.0140242, 0.0509646, 0.00588226},
{0.138626, 0.0629815,
0.272169},
{0.0585034, 0.0750587, 1.},
{0.153123, 0.12154,
0.0680384},
{0.212751, 0.210508, 0.0768402},
{0.217497, 0.189625,
0.172107},
{0.20766, 0.142682, 0.246233},
{0.246923, 0.110408,
0.251928},
{0.0924592, 0.20464, 0.07382}}
Also
Flatten[Partition[nums, {3, 3}], {3, 4, 1}]
same result
$endgroup$
add a comment |
$begingroup$
Flatten[Transpose@Partition[#,3]&/@nums,1]
{{0.0140242,0.0509646,0.00588226},
{0.138626,0.0629815,0.272169},
{0.0585034,0.0750587,1.},
{0.153123,0.12154,0.0680384},
{0.212751,0.210508,0.0768402},
{0.217497,0.189625,0.172107},
{0.20766,0.142682,0.246233},
{0.246923,0.110408,0.251928},
{0.0924592,0.20464,0.07382}}
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f186677%2fpartitioning-sublists-based-on-positions-with-new-partitions-immediately-follow%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Join @@ Transpose[nums[[All, # ;; ;; 3]] & /@ {1, 2, 3}]
{{0.0140242, 0.0509646, 0.00588226},
{0.138626, 0.0629815,
0.272169},
{0.0585034, 0.0750587, 1.},
{0.153123, 0.12154,
0.0680384},
{0.212751, 0.210508, 0.0768402},
{0.217497, 0.189625,
0.172107},
{0.20766, 0.142682, 0.246233},
{0.246923, 0.110408,
0.251928},
{0.0924592, 0.20464, 0.07382}}
Also
Flatten[Partition[nums, {3, 3}], {3, 4, 1}]
same result
$endgroup$
add a comment |
$begingroup$
Join @@ Transpose[nums[[All, # ;; ;; 3]] & /@ {1, 2, 3}]
{{0.0140242, 0.0509646, 0.00588226},
{0.138626, 0.0629815,
0.272169},
{0.0585034, 0.0750587, 1.},
{0.153123, 0.12154,
0.0680384},
{0.212751, 0.210508, 0.0768402},
{0.217497, 0.189625,
0.172107},
{0.20766, 0.142682, 0.246233},
{0.246923, 0.110408,
0.251928},
{0.0924592, 0.20464, 0.07382}}
Also
Flatten[Partition[nums, {3, 3}], {3, 4, 1}]
same result
$endgroup$
add a comment |
$begingroup$
Join @@ Transpose[nums[[All, # ;; ;; 3]] & /@ {1, 2, 3}]
{{0.0140242, 0.0509646, 0.00588226},
{0.138626, 0.0629815,
0.272169},
{0.0585034, 0.0750587, 1.},
{0.153123, 0.12154,
0.0680384},
{0.212751, 0.210508, 0.0768402},
{0.217497, 0.189625,
0.172107},
{0.20766, 0.142682, 0.246233},
{0.246923, 0.110408,
0.251928},
{0.0924592, 0.20464, 0.07382}}
Also
Flatten[Partition[nums, {3, 3}], {3, 4, 1}]
same result
$endgroup$
Join @@ Transpose[nums[[All, # ;; ;; 3]] & /@ {1, 2, 3}]
{{0.0140242, 0.0509646, 0.00588226},
{0.138626, 0.0629815,
0.272169},
{0.0585034, 0.0750587, 1.},
{0.153123, 0.12154,
0.0680384},
{0.212751, 0.210508, 0.0768402},
{0.217497, 0.189625,
0.172107},
{0.20766, 0.142682, 0.246233},
{0.246923, 0.110408,
0.251928},
{0.0924592, 0.20464, 0.07382}}
Also
Flatten[Partition[nums, {3, 3}], {3, 4, 1}]
same result
edited Nov 26 '18 at 0:16
answered Nov 25 '18 at 23:24
kglrkglr
189k10206424
189k10206424
add a comment |
add a comment |
$begingroup$
Flatten[Transpose@Partition[#,3]&/@nums,1]
{{0.0140242,0.0509646,0.00588226},
{0.138626,0.0629815,0.272169},
{0.0585034,0.0750587,1.},
{0.153123,0.12154,0.0680384},
{0.212751,0.210508,0.0768402},
{0.217497,0.189625,0.172107},
{0.20766,0.142682,0.246233},
{0.246923,0.110408,0.251928},
{0.0924592,0.20464,0.07382}}
$endgroup$
add a comment |
$begingroup$
Flatten[Transpose@Partition[#,3]&/@nums,1]
{{0.0140242,0.0509646,0.00588226},
{0.138626,0.0629815,0.272169},
{0.0585034,0.0750587,1.},
{0.153123,0.12154,0.0680384},
{0.212751,0.210508,0.0768402},
{0.217497,0.189625,0.172107},
{0.20766,0.142682,0.246233},
{0.246923,0.110408,0.251928},
{0.0924592,0.20464,0.07382}}
$endgroup$
add a comment |
$begingroup$
Flatten[Transpose@Partition[#,3]&/@nums,1]
{{0.0140242,0.0509646,0.00588226},
{0.138626,0.0629815,0.272169},
{0.0585034,0.0750587,1.},
{0.153123,0.12154,0.0680384},
{0.212751,0.210508,0.0768402},
{0.217497,0.189625,0.172107},
{0.20766,0.142682,0.246233},
{0.246923,0.110408,0.251928},
{0.0924592,0.20464,0.07382}}
$endgroup$
Flatten[Transpose@Partition[#,3]&/@nums,1]
{{0.0140242,0.0509646,0.00588226},
{0.138626,0.0629815,0.272169},
{0.0585034,0.0750587,1.},
{0.153123,0.12154,0.0680384},
{0.212751,0.210508,0.0768402},
{0.217497,0.189625,0.172107},
{0.20766,0.142682,0.246233},
{0.246923,0.110408,0.251928},
{0.0924592,0.20464,0.07382}}
edited Nov 25 '18 at 23:33
answered Nov 25 '18 at 23:20
J42161217J42161217
3,968323
3,968323
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f186677%2fpartitioning-sublists-based-on-positions-with-new-partitions-immediately-follow%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown