List manipulation: conditional result based on variable-length sublistsSelect rows of matrix that are higher than a given rowSplitting a list into increasing sublistsGroup list by rules in sequence using DateDifference and TotalPartition list into $n$ sublistsListing all distinct exhaustive combinations of sublists of a certain lengthRemove the right sublistlist manipulation by ruleSort a list in a descending orderSpecific list manipulationSelect list elements based on other list
Two palindromes are not enough
Why was Pan Am Flight 103 flying over Lockerbie?
The Lucas argument vs the theorem-provers--who wins and why?
Word ending in "-ine" for rat-like
How did they film the Invisible Man being invisible, in 1933?
Does friction always oppose motion?
Could you fall off a planet if it was being accelerated by engines?
Making a wall made from glass bricks
How can I know if a PDF file was created via LaTeX or XeLaTeX?
If a USA citizen marries a foreign citizen who has a kid from a previous marriage
A quine of sorts
What was the point of separating stdout and stderr?
Can a successful book series let the bad guy win?
Discworld quote about an "old couple" who having said everything to each other, can finally go about living their lives
How can I open this door latch with the knobs removed?
Can I use Alchemist's fire to turn my sword into a virtual Flame Blade?
Why isn't UDP with reliability (implemented at Application layer) a substitute of TCP?
Can European countries bypass the EU and make their own individual trade deal with the U.S.?
Which is better for keeping data: primary partition or logical partition?
How do I ensure my employees don't abuse my flexible work hours policy?
Undetectable mail tracker
Cup and Trade: The Perfect Nutmeg Soup
How does mmorpg store data?
How can I deal with extreme temperatures in a hotel room?
List manipulation: conditional result based on variable-length sublists
Select rows of matrix that are higher than a given rowSplitting a list into increasing sublistsGroup list by rules in sequence using DateDifference and TotalPartition list into $n$ sublistsListing all distinct exhaustive combinations of sublists of a certain lengthRemove the right sublistlist manipulation by ruleSort a list in a descending orderSpecific list manipulationSelect list elements based on other list
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
Suppose I have the following lists:
eqexp=a,b,c,d
eqval=e,f,g,h
signval=,1,-1,1,-1
I want to create a new list of inequalities, where the signval list signals whether to use greater than or less than. I need it to handle empty sublists, and multi-component sublists. My desired output is:
,b>f,c<g,d>h,d<h
All lists have the same number of top-level elements. eqexp and eqval are one-dimensional. signval is two-dimensional, but the length of the sub-lists is variable. The only numerical values allowed in signval are 1 and -1.
How do I do this?
list-manipulation
$endgroup$
add a comment |
$begingroup$
Suppose I have the following lists:
eqexp=a,b,c,d
eqval=e,f,g,h
signval=,1,-1,1,-1
I want to create a new list of inequalities, where the signval list signals whether to use greater than or less than. I need it to handle empty sublists, and multi-component sublists. My desired output is:
,b>f,c<g,d>h,d<h
All lists have the same number of top-level elements. eqexp and eqval are one-dimensional. signval is two-dimensional, but the length of the sub-lists is variable. The only numerical values allowed in signval are 1 and -1.
How do I do this?
list-manipulation
$endgroup$
add a comment |
$begingroup$
Suppose I have the following lists:
eqexp=a,b,c,d
eqval=e,f,g,h
signval=,1,-1,1,-1
I want to create a new list of inequalities, where the signval list signals whether to use greater than or less than. I need it to handle empty sublists, and multi-component sublists. My desired output is:
,b>f,c<g,d>h,d<h
All lists have the same number of top-level elements. eqexp and eqval are one-dimensional. signval is two-dimensional, but the length of the sub-lists is variable. The only numerical values allowed in signval are 1 and -1.
How do I do this?
list-manipulation
$endgroup$
Suppose I have the following lists:
eqexp=a,b,c,d
eqval=e,f,g,h
signval=,1,-1,1,-1
I want to create a new list of inequalities, where the signval list signals whether to use greater than or less than. I need it to handle empty sublists, and multi-component sublists. My desired output is:
,b>f,c<g,d>h,d<h
All lists have the same number of top-level elements. eqexp and eqval are one-dimensional. signval is two-dimensional, but the length of the sub-lists is variable. The only numerical values allowed in signval are 1 and -1.
How do I do this?
list-manipulation
list-manipulation
edited 8 hours ago
user64494
4,1242 gold badges14 silver badges23 bronze badges
4,1242 gold badges14 silver badges23 bronze badges
asked 9 hours ago
Kevin AusmanKevin Ausman
8152 silver badges15 bronze badges
8152 silver badges15 bronze badges
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
$begingroup$
MapThread[#3 /. 1 -> #1 > #2, -1 -> #1 < #2 &, eqexp, eqval, signval]
(* , b > f, c < g, d > h, d < h *)
$endgroup$
$begingroup$
Nice! I'm embarrassed that I didn't come up with that. Thank you!
$endgroup$
– Kevin Ausman
9 hours ago
add a comment |
$begingroup$
And the power of posting... I have found a way to do it:
MapThread[
Function[a, b, c, If[c > 0, a > b, a < b], Listable],
eqexp, eqval, signval]
If there is a better way to do it, I would love to see it, though!
$endgroup$
add a comment |
$begingroup$
Which[
#1 === , ,
#1 === 1, #2 > #3,
#1 === -1, #2 < #3,
#1 === 1, -1,
#2 > #3, #2 < #3]&
@@@ Transpose[signval, eqexp, eqval]
(* ,b>f,c<g,d>h,d<h *)
$endgroup$
add a comment |
$begingroup$
MapThread[Through @ # @ ##2 &, signval /. 1 -> Greater, -1 -> Less, eqexp, eqval]
, b > f, c < g, d > h, d < h
Also
Function[x, y, z, x[y, z], Listable][signval /. 1 -> Greater, -1 -> Less, eqexp, eqval]
, b > f, c < g, d > h, d < h
$endgroup$
add a comment |
Your Answer
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%2f201123%2flist-manipulation-conditional-result-based-on-variable-length-sublists%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
MapThread[#3 /. 1 -> #1 > #2, -1 -> #1 < #2 &, eqexp, eqval, signval]
(* , b > f, c < g, d > h, d < h *)
$endgroup$
$begingroup$
Nice! I'm embarrassed that I didn't come up with that. Thank you!
$endgroup$
– Kevin Ausman
9 hours ago
add a comment |
$begingroup$
MapThread[#3 /. 1 -> #1 > #2, -1 -> #1 < #2 &, eqexp, eqval, signval]
(* , b > f, c < g, d > h, d < h *)
$endgroup$
$begingroup$
Nice! I'm embarrassed that I didn't come up with that. Thank you!
$endgroup$
– Kevin Ausman
9 hours ago
add a comment |
$begingroup$
MapThread[#3 /. 1 -> #1 > #2, -1 -> #1 < #2 &, eqexp, eqval, signval]
(* , b > f, c < g, d > h, d < h *)
$endgroup$
MapThread[#3 /. 1 -> #1 > #2, -1 -> #1 < #2 &, eqexp, eqval, signval]
(* , b > f, c < g, d > h, d < h *)
answered 9 hours ago


RomanRoman
12k1 gold badge19 silver badges46 bronze badges
12k1 gold badge19 silver badges46 bronze badges
$begingroup$
Nice! I'm embarrassed that I didn't come up with that. Thank you!
$endgroup$
– Kevin Ausman
9 hours ago
add a comment |
$begingroup$
Nice! I'm embarrassed that I didn't come up with that. Thank you!
$endgroup$
– Kevin Ausman
9 hours ago
$begingroup$
Nice! I'm embarrassed that I didn't come up with that. Thank you!
$endgroup$
– Kevin Ausman
9 hours ago
$begingroup$
Nice! I'm embarrassed that I didn't come up with that. Thank you!
$endgroup$
– Kevin Ausman
9 hours ago
add a comment |
$begingroup$
And the power of posting... I have found a way to do it:
MapThread[
Function[a, b, c, If[c > 0, a > b, a < b], Listable],
eqexp, eqval, signval]
If there is a better way to do it, I would love to see it, though!
$endgroup$
add a comment |
$begingroup$
And the power of posting... I have found a way to do it:
MapThread[
Function[a, b, c, If[c > 0, a > b, a < b], Listable],
eqexp, eqval, signval]
If there is a better way to do it, I would love to see it, though!
$endgroup$
add a comment |
$begingroup$
And the power of posting... I have found a way to do it:
MapThread[
Function[a, b, c, If[c > 0, a > b, a < b], Listable],
eqexp, eqval, signval]
If there is a better way to do it, I would love to see it, though!
$endgroup$
And the power of posting... I have found a way to do it:
MapThread[
Function[a, b, c, If[c > 0, a > b, a < b], Listable],
eqexp, eqval, signval]
If there is a better way to do it, I would love to see it, though!
answered 9 hours ago
Kevin AusmanKevin Ausman
8152 silver badges15 bronze badges
8152 silver badges15 bronze badges
add a comment |
add a comment |
$begingroup$
Which[
#1 === , ,
#1 === 1, #2 > #3,
#1 === -1, #2 < #3,
#1 === 1, -1,
#2 > #3, #2 < #3]&
@@@ Transpose[signval, eqexp, eqval]
(* ,b>f,c<g,d>h,d<h *)
$endgroup$
add a comment |
$begingroup$
Which[
#1 === , ,
#1 === 1, #2 > #3,
#1 === -1, #2 < #3,
#1 === 1, -1,
#2 > #3, #2 < #3]&
@@@ Transpose[signval, eqexp, eqval]
(* ,b>f,c<g,d>h,d<h *)
$endgroup$
add a comment |
$begingroup$
Which[
#1 === , ,
#1 === 1, #2 > #3,
#1 === -1, #2 < #3,
#1 === 1, -1,
#2 > #3, #2 < #3]&
@@@ Transpose[signval, eqexp, eqval]
(* ,b>f,c<g,d>h,d<h *)
$endgroup$
Which[
#1 === , ,
#1 === 1, #2 > #3,
#1 === -1, #2 < #3,
#1 === 1, -1,
#2 > #3, #2 < #3]&
@@@ Transpose[signval, eqexp, eqval]
(* ,b>f,c<g,d>h,d<h *)
edited 3 hours ago


m_goldberg
90.6k8 gold badges75 silver badges203 bronze badges
90.6k8 gold badges75 silver badges203 bronze badges
answered 6 hours ago
user1066user1066
6,3982 gold badges20 silver badges33 bronze badges
6,3982 gold badges20 silver badges33 bronze badges
add a comment |
add a comment |
$begingroup$
MapThread[Through @ # @ ##2 &, signval /. 1 -> Greater, -1 -> Less, eqexp, eqval]
, b > f, c < g, d > h, d < h
Also
Function[x, y, z, x[y, z], Listable][signval /. 1 -> Greater, -1 -> Less, eqexp, eqval]
, b > f, c < g, d > h, d < h
$endgroup$
add a comment |
$begingroup$
MapThread[Through @ # @ ##2 &, signval /. 1 -> Greater, -1 -> Less, eqexp, eqval]
, b > f, c < g, d > h, d < h
Also
Function[x, y, z, x[y, z], Listable][signval /. 1 -> Greater, -1 -> Less, eqexp, eqval]
, b > f, c < g, d > h, d < h
$endgroup$
add a comment |
$begingroup$
MapThread[Through @ # @ ##2 &, signval /. 1 -> Greater, -1 -> Less, eqexp, eqval]
, b > f, c < g, d > h, d < h
Also
Function[x, y, z, x[y, z], Listable][signval /. 1 -> Greater, -1 -> Less, eqexp, eqval]
, b > f, c < g, d > h, d < h
$endgroup$
MapThread[Through @ # @ ##2 &, signval /. 1 -> Greater, -1 -> Less, eqexp, eqval]
, b > f, c < g, d > h, d < h
Also
Function[x, y, z, x[y, z], Listable][signval /. 1 -> Greater, -1 -> Less, eqexp, eqval]
, b > f, c < g, d > h, d < h
edited 2 hours ago
answered 2 hours ago
kglrkglr
201k10 gold badges230 silver badges458 bronze badges
201k10 gold badges230 silver badges458 bronze badges
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%2f201123%2flist-manipulation-conditional-result-based-on-variable-length-sublists%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